diff --git a/src/components/Header.astro b/src/components/Header.astro index 43a4a7168..e0b1144fb 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -4,7 +4,7 @@ import Hr from "./Hr.astro"; import LinkButton from "./LinkButton.astro"; export interface Props { - activeNav?: "posts" | "tags" | "about" | "search"; + activeNav?: "posts" | "archives" | "tags" | "about" | "search"; } const { activeNav } = Astro.props; @@ -70,6 +70,41 @@ const { activeNav } = Astro.props; About + { + SITE.showArchives && ( +
  • + + + <> + + + + + + + + Archives + + +
  • + ) + }
  • !data.draft); + +const MonthMap: Record = { + "1": "January", + "2": "February", + "3": "March", + "4": "April", + "5": "May", + "6": "June", + "7": "July", + "8": "August", + "9": "September", + "10": "October", + "11": "November", + "12": "December", +}; +--- + + +
    +
    + { + Object.entries( + getPostsByGroupCondition(posts, post => + post.data.pubDatetime.getFullYear() + ) + ) + .sort(([yearA], [yearB]) => Number(yearB) - Number(yearA)) + .map(([year, yearGroup]) => ( +
    + {year} + {yearGroup.length} + {Object.entries( + getPostsByGroupCondition( + yearGroup, + post => post.data.pubDatetime.getMonth() + 1 + ) + ) + .sort(([monthA], [monthB]) => Number(monthB) - Number(monthA)) + .map(([month, monthGroup]) => ( +
    +
    + {MonthMap[month]} + {monthGroup.length} +
    +
      + {monthGroup.map(({ data, slug }) => ( + + ))} +
    +
    + ))} +
    + )) + } +
    + +