diff --git a/src/components/ThoughtCard.astro b/src/components/ThoughtCard.astro index 5290bec..370d108 100644 --- a/src/components/ThoughtCard.astro +++ b/src/components/ThoughtCard.astro @@ -31,7 +31,7 @@ const { > {format(date, "MMMM dd, yyyy")} - · + diff --git a/src/content/thoughts/remove-file-from-git-history.mdx b/src/content/micro/remove-file-from-git-history.mdx similarity index 92% rename from src/content/thoughts/remove-file-from-git-history.mdx rename to src/content/micro/remove-file-from-git-history.mdx index 3d5d53f..44b42f4 100644 --- a/src/content/thoughts/remove-file-from-git-history.mdx +++ b/src/content/micro/remove-file-from-git-history.mdx @@ -1,9 +1,7 @@ --- title: "How to remove file from Git history" -pubDate: 2024-01-08 +date: 2024-01-08 published: true -author: "Bhekani Khumalo" -tags: ["git"] --- I have googled this enough times for me to keep it in my own notes. diff --git a/src/pages/thoughts/index.astro b/src/pages/thoughts/index.astro index de1ba73..433a227 100644 --- a/src/pages/thoughts/index.astro +++ b/src/pages/thoughts/index.astro @@ -1,24 +1,34 @@ --- -import { getCollection } from "astro:content"; -import AllTags from "../../components/AllTags.astro"; -import LatestThoughtCard from "../../components/LatestThoughtCard.astro"; -import MainContainer from "../../components/MainContainer.astro"; -import ThoughtCard from "../../components/ThoughtCard.astro"; -import BaseLayout from "../../layouts/BaseLayout.astro"; +import { getCollection, type CollectionEntry } from "astro:content" +import AllTags from "../../components/AllTags.astro" +import MainContainer from "../../components/MainContainer.astro" +import ThoughtCard from "../../components/ThoughtCard.astro" +import BaseLayout from "../../layouts/BaseLayout.astro" -const allThoughts = await getCollection("thoughts"); +const allThoughts = await getCollection("thoughts") const sortedThoughts = allThoughts.sort( - (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf() -); -const firstThought = sortedThoughts.shift(); -const pageTitle = "Thoughts"; + (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf(), +) +// const firstThought = sortedThoughts.shift() + +const yearToThoughts = sortedThoughts.reduce< + Record[]> +>((acc, thought) => { + const year = new Date(thought.data.pubDate).getFullYear() + if (!acc[year]) { + acc[year] = [] + } + acc[year].push(thought) + return acc +}, {}) +const pageTitle = "Thoughts" --- - {firstThought && } -
- {sortedThoughts.map((thought) => )} -
+ + + { + Object.entries(yearToThoughts) + .sort((a, b) => Number(b[0]) - Number(a[0])) + .map(([year, thoughts]) => ( + <> +

+ {year} ({thoughts.length}) +

+
+ {thoughts.map((thought) => ( + + ))} +
+ + )) + }