diff --git a/src/components/BlogPost.astro b/src/components/BlogPost.astro index 262805c..0a09f26 100644 --- a/src/components/BlogPost.astro +++ b/src/components/BlogPost.astro @@ -1,11 +1,11 @@ --- interface Props { - title: string; - published_at: Date; - slug: string; + title: string; + publishedAt: string; + slug: string; } -const { title, published_at, slug } = Astro.props; +const { title, publishedAt, slug } = Astro.props; import Link from "@components/Link.astro"; --- @@ -17,11 +17,11 @@ import Link from "@components/Link.astro"; {title} diff --git a/src/content.config.ts b/src/content.config.ts index af7a754..9eddd4f 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -1,8 +1,19 @@ -import { defineCollection } from "astro:content"; +import { defineCollection, z } from "astro:content"; import { leafletStaticLoader } from "@nulfrost/leaflet-loader-astro"; +import { glob } from "astro/loaders"; + +const blogs = defineCollection({ + loader: glob({ pattern: "**/*.mdx", base: "./src/data/blog" }), + schema: z.object({ + title: z.string(), + description: z.string(), + year: z.number(), + published_at: z.date(), + }), +}); const documents = defineCollection({ loader: leafletStaticLoader({ repo: "did:plc:qttsv4e7pu2jl3ilanfgc3zn" }), }); -export const collections = { documents }; +export const collections = { documents, blogs }; diff --git a/src/pages/blogs/index.astro b/src/pages/blogs/index.astro index fca021d..7f3779c 100644 --- a/src/pages/blogs/index.astro +++ b/src/pages/blogs/index.astro @@ -3,9 +3,11 @@ import Layout from "@layouts/Layout.astro"; import BlogPost from "@components/BlogPost.astro"; import { getCollection } from "astro:content"; -const posts = (await getCollection("blog")).sort( - (a, b) => b.data.published_at.valueOf() - a.data.published_at.valueOf(), -); +// const posts = (await getCollection("blogs")).sort( +// (a, b) => b.data.published_at.valueOf() - a.data.published_at.valueOf(), +// ); + +const documents = await getCollection("documents"); --- Blog