diff --git a/package.json b/package.json index 1f83abd..d962fdf 100755 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/rss": "^3.0.0", - "astro": "^2.10.7" + "@astrojs/mdx": "^2.1.1", + "@astrojs/rss": "^4.0.4", + "@astrojs/sitemap": "^3.0.5", + "astro": "^4.3.2" } } diff --git a/src/pages/posts/post-1.md b/src/content/blog/post-1.md similarity index 100% rename from src/pages/posts/post-1.md rename to src/content/blog/post-1.md diff --git a/src/content/config.ts b/src/content/config.ts new file mode 100644 index 0000000..667a31c --- /dev/null +++ b/src/content/config.ts @@ -0,0 +1,16 @@ +import { defineCollection, z } from 'astro:content'; + +const blog = defineCollection({ + type: 'content', + // Type-check frontmatter using a schema + schema: z.object({ + title: z.string(), + description: z.string(), + // Transform string to Date object + pubDate: z.coerce.date(), + updatedDate: z.coerce.date().optional(), + heroImage: z.string().optional(), + }), +}); + +export const collections = { blog }; diff --git a/src/layouts/BlogPost.astro b/src/layouts/BlogPost.astro new file mode 100644 index 0000000..e67b2b3 --- /dev/null +++ b/src/layouts/BlogPost.astro @@ -0,0 +1,85 @@ +--- +import type { CollectionEntry } from 'astro:content'; +import BaseHead from '../components/BaseHead.astro'; +import Header from '../components/Header.astro'; +import Footer from '../components/Footer.astro'; +import FormattedDate from '../components/FormattedDate.astro'; + +type Props = CollectionEntry<'blog'>['data']; + +const { title, description, pubDate, updatedDate, heroImage } = Astro.props; +--- + + + + + + + + +
+
+
+
+ {heroImage && } +
+
+
+
+ + { + updatedDate && ( +
+ Last updated on +
+ ) + } +
+

{title}

+
+
+ +
+
+
+