Luke Jones

lukeonline - commit af4e904

fix: contentloader fixesaf4e90435587b2a6f333ea95d11d726d05470457LukeJ<luke.jones.2567@gmail.com>2026-07-15T19:51:20+01:00
diff --git a/package.json b/package.json index 723b0a8..bfef8aa 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "license": "GPL-2.0-or-later", "author": "luke jones", - "type": "commonjs", + "type": "module", "main": "index.js", "scripts": { "dev": "astro dev", diff --git a/src/components/Header.astro b/src/components/Header.astro index 6543e09..a982e20 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -5,8 +5,9 @@ const { title } = Astro.props; <h1 class="text-2xl font-bold">Luke Jones</h1> <nav class="flex flex-row gap-6"> <a href="/">Home</a> - <a href="/blog">Blog</a> <a href="/projects">Projects</a> + <a href="/blog">Blog</a> + <a href="/photos">Photos</a> <a href="/about">About</a> </nav> </header> diff --git a/src/content.config.ts b/src/content.config.ts new file mode 100644 index 0000000..0016bae --- /dev/null +++ b/src/content.config.ts @@ -0,0 +1,11 @@ +import { defineCollection } from 'astro:content'; +import { glob } from 'astro/loaders'; + +const blog = defineCollection({ + loader: glob({ + base: './src/content/blog', + pattern: '**/*.md', + }), +}); + +export const collections = { blog }; diff --git a/src/content/blog/example1.md b/src/content/blog/example1.md new file mode 100644 index 0000000..416a219 --- /dev/null +++ b/src/content/blog/example1.md @@ -0,0 +1,6 @@ +--- +title: Example Blog 1 +desc: An example of a blog +date: 2026-01-01 +--- +This is an example blog post diff --git a/src/content/blog/example2.md b/src/content/blog/example2.md new file mode 100644 index 0000000..bff9592 --- /dev/null +++ b/src/content/blog/example2.md @@ -0,0 +1,6 @@ +--- +title: Example Blog 2 +desc: An example of another blog +date: 2026-01-02 +--- +This is another example blog post diff --git a/src/layouts/ContentList.astro b/src/layouts/ContentList.astro index 8cbd921..461e02f 100644 --- a/src/layouts/ContentList.astro +++ b/src/layouts/ContentList.astro @@ -5,4 +5,10 @@ const { ...props } = Astro.props; --- <Base title={props.title}> <slot /> + {props.content.map(post => ( + <div> + <span>{post.title}</span> + <span>{post.desc}</span> + </div> + ))} </Base> diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 76f3355..dfdd0a2 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -2,10 +2,17 @@ import ContentList from "../../layouts/ContentList.astro"; import TextSection from "../../components/TextSection.astro"; -const title = "Blogs"; +import { getCollection, getEntry } from 'astro:content'; + +const title = "Blog"; + +const blogPosts = await getCollection('blog'); + +const contentData = blogPosts.map((post) => ({ + title: post.data.title, + desc: `${post.data.desc} - ${post.data.date.toLocaleDateString()}` +})); + +console.log('POSTS: ', blogPosts) --- -<ContentList title={title}> - <TextSection> - This is a body of text - </TextSection> -</ContentList> +<ContentList title={title} content={contentData} />