Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* extract notes * description and spacing * first note
- Loading branch information
1 parent
435b3cc
commit edd01f7
Showing
6 changed files
with
78 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
published: 2024-01-25T09:15:49-0500 | ||
--- | ||
|
||
Moved [notes](https://github.com/alexcarpenter/alexcarpenter.me/pull/140) to its own collection. This adds a bit more flexibility for authoring notes that I was looking for. I can now create multiple paragraphs, blockquotes, and code blocks, etc. |
5 changes: 3 additions & 2 deletions
5
src/content/pages/notes.md → src/content/pages/notes-archive.md
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
import Base from "@/layouts/BaseLayout.astro"; | ||
import FormattedDate, { | ||
parseDateToString, | ||
} from "@/components/FormattedDate.astro"; | ||
import { getCollection, type CollectionEntry } from "astro:content"; | ||
type NoteProps = CollectionEntry<"notes">; | ||
const notes = await getCollection("notes"); | ||
const sortedNotes = notes.sort((a, b) => { | ||
const aDate = a.data.published; | ||
const bDate = b.data.published; | ||
return Date.parse(bDate.toString()) - Date.parse(aDate.toString()); | ||
}); | ||
const groupedNotes = groupByDay(sortedNotes); | ||
function groupByDay(items: NoteProps[]): Record<string, NoteProps[]> { | ||
const grouped: Record<string, NoteProps[]> = {}; | ||
items.forEach((item) => { | ||
const key = parseDateToString(item.data.published.toString()); | ||
if (!grouped[key]) { | ||
grouped[key] = []; | ||
} | ||
grouped[key].push(item); | ||
}); | ||
return grouped; | ||
} | ||
--- | ||
|
||
<Base> | ||
<header class="relative mb-6 border-b-2 pb-2 pr-12"> | ||
<h1 class="font-bold">Notes</h1> | ||
<p class="text-pretty text-secondary">Short-form thoughts and updates</p> | ||
</header> | ||
<main class="flex-grow"> | ||
<div class="prose"> | ||
<dl> | ||
{ | ||
Object.entries(groupedNotes).map(([date, notes]) => { | ||
return ( | ||
<> | ||
<dt id={date}> | ||
<FormattedDate date={new Date(date)} /> | ||
</dt> | ||
{notes.map((note) => | ||
note.render().then(({ Content }) => ( | ||
<dd class="grid gap-y-2"> | ||
<Content /> | ||
</dd> | ||
)) | ||
)} | ||
</> | ||
); | ||
}) | ||
} | ||
</dl> | ||
</div> | ||
</main> | ||
</Base> |
edd01f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
alexcarpenter-next – ./
alexcarpenter-next-alexcarpenter.vercel.app
alexcarpenter.vercel.app
alexcarpenter-next-git-main-alexcarpenter.vercel.app
www.alexcarpenter.me
alexcarpenter.me