From edd01f74dbe4815d6f383f9759c810a389de53a1 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Thu, 25 Jan 2024 09:42:06 -0500 Subject: [PATCH] extract notes (#140) * extract notes * description and spacing * first note --- src/components/FormattedDate.astro | 2 +- src/content/config.ts | 9 ++- src/content/notes/2024-01-25-1.md | 5 ++ .../pages/{notes.md => notes-archive.md} | 5 +- src/pages/index.astro | 4 ++ src/pages/notes.astro | 57 +++++++++++++++++++ 6 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 src/content/notes/2024-01-25-1.md rename src/content/pages/{notes.md => notes-archive.md} (98%) create mode 100644 src/pages/notes.astro diff --git a/src/components/FormattedDate.astro b/src/components/FormattedDate.astro index e94f0c04..ac7d31da 100644 --- a/src/components/FormattedDate.astro +++ b/src/components/FormattedDate.astro @@ -1,7 +1,7 @@ --- import { format } from "date-fns"; -const parseDateToString = (date: string): string => { +export const parseDateToString = (date: string): string => { const d = new Date(date); const t = new Date(d.valueOf() + d.getTimezoneOffset() * 60 * 1000); return format(t, "yyyy-MM-dd"); diff --git a/src/content/config.ts b/src/content/config.ts index 798d1f84..7d50bea9 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,5 +1,12 @@ import { defineCollection, z } from "astro:content"; +const notes = defineCollection({ + type: "content", + schema: z.object({ + published: z.coerce.date(), + }), +}); + const pages = defineCollection({ type: "content", schema: z.object({ @@ -12,4 +19,4 @@ const pages = defineCollection({ }), }); -export const collections = { pages }; +export const collections = { notes, pages }; diff --git a/src/content/notes/2024-01-25-1.md b/src/content/notes/2024-01-25-1.md new file mode 100644 index 00000000..2fef999e --- /dev/null +++ b/src/content/notes/2024-01-25-1.md @@ -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. diff --git a/src/content/pages/notes.md b/src/content/pages/notes-archive.md similarity index 98% rename from src/content/pages/notes.md rename to src/content/pages/notes-archive.md index dfbb1adf..84ef56e7 100644 --- a/src/content/pages/notes.md +++ b/src/content/pages/notes-archive.md @@ -1,9 +1,10 @@ --- -title: Notes +title: Notes archive description: Short-form thoughts and updates published: 2023-12-31 updated: 2024-01-21 -pinned: true +# pinned: true +draft: true --- 2024-01-23 diff --git a/src/pages/index.astro b/src/pages/index.astro index e0043a27..449296aa 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -11,6 +11,10 @@ const pages = await getCollection("pages", ({ data }) => {

Pinned