-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...thoughts/remove-file-from-git-history.mdx → ...nt/micro/remove-file-from-git-history.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,58 @@ | ||
--- | ||
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<number, CollectionEntry<"thoughts">[]> | ||
>((acc, thought) => { | ||
const year = new Date(thought.data.pubDate).getFullYear() | ||
if (!acc[year]) { | ||
acc[year] = [] | ||
} | ||
acc[year].push(thought) | ||
return acc | ||
}, {}) | ||
const pageTitle = "Thoughts" | ||
--- | ||
|
||
<BaseLayout pageTitle={pageTitle}> | ||
<MainContainer> | ||
<div class="w-full flex justify-center mb-8 font-bold"> | ||
<a | ||
class="px-3 p-2 text-[hsl(var(--foreground))] border-b-[1px] border-l-[1px] border-r-[1px] border-[hsl(var(--muted))]" | ||
class="px-3 p-2 text- border-b-[1px] border-l-[1px] border-r-[1px] border-[hsl(var(--muted))]" | ||
href="/rss.xml" | ||
> | ||
Subscribe to RSS | ||
</a> | ||
</div> | ||
|
||
<AllTags title="Filter by tag" /> | ||
{firstThought && <LatestThoughtCard thought={firstThought} />} | ||
<div class="grid gap-4"> | ||
{sortedThoughts.map((thought) => <ThoughtCard thought={thought} />)} | ||
</div> | ||
<!-- {firstThought && <LatestThoughtCard thought={firstThought} />} --> | ||
|
||
{ | ||
Object.entries(yearToThoughts) | ||
.sort((a, b) => Number(b[0]) - Number(a[0])) | ||
.map(([year, thoughts]) => ( | ||
<> | ||
<h2 class="text-2xl mb-4 border-b-2 mt-8 pb-2"> | ||
{year} ({thoughts.length}) | ||
</h2> | ||
<div class="grid gap-4"> | ||
{thoughts.map((thought) => ( | ||
<ThoughtCard thought={thought} /> | ||
))} | ||
</div> | ||
</> | ||
)) | ||
} | ||
</MainContainer> | ||
</BaseLayout> |