diff --git a/src/content/config.ts b/src/content/config.ts index 2a3f37e..f0cc13e 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,11 +1,17 @@ import { defineCollection } from 'astro:content'; -import { blogs } from './blog/_schemas'; +import { posts } from './posts/_schemas'; +import { pages } from "./pages/_schemas"; const blogCollection = defineCollection({ type: 'content', - schema: blogs, + schema: posts, +}); +const pageCollection = defineCollection({ + type: 'content', + schema: pages, }); export const collections = { - 'blog': blogCollection, + 'posts': blogCollection, + 'pages': pageCollection, }; \ No newline at end of file diff --git a/src/content/blog/_schemas.ts b/src/content/posts/_schemas.ts similarity index 85% rename from src/content/blog/_schemas.ts rename to src/content/posts/_schemas.ts index 23945ba..a1e7613 100644 --- a/src/content/blog/_schemas.ts +++ b/src/content/posts/_schemas.ts @@ -1,6 +1,6 @@ import { z } from 'astro:content'; -export const blogs = z.object({ +export const posts = z.object({ title: z.string(), description: z.string(), pubDate: z.coerce.date(), diff --git a/src/content/blog/first-post.md b/src/content/posts/first-post.md similarity index 100% rename from src/content/blog/first-post.md rename to src/content/posts/first-post.md diff --git a/src/content/blog/minimalism.md b/src/content/posts/minimalism.md similarity index 100% rename from src/content/blog/minimalism.md rename to src/content/posts/minimalism.md diff --git a/src/content/blog/terminal-setup.md b/src/content/posts/terminal-setup.md similarity index 100% rename from src/content/blog/terminal-setup.md rename to src/content/posts/terminal-setup.md diff --git a/src/pages/blog.astro b/src/pages/blog.astro index 69a0a2b..baab6e9 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -2,7 +2,7 @@ import Layout from '../layouts/Layout.astro'; import { getCollection } from 'astro:content'; -const posts = await getCollection('blog'); +const posts = await getCollection('posts'); posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime()); --- @@ -18,7 +18,7 @@ posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDat {posts.map((post) => (

{new Date(post.data.pubDate).toISOString().split('T')[0]} - {post.data.title} + {post.data.title}

))} diff --git a/src/pages/blog/[...slug].astro b/src/pages/post/[...slug].astro similarity index 97% rename from src/pages/blog/[...slug].astro rename to src/pages/post/[...slug].astro index 56d86fd..2826d2d 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/post/[...slug].astro @@ -3,7 +3,7 @@ import Layout from '../../layouts/Layout.astro'; import { getCollection } from 'astro:content'; export async function getStaticPaths() { - const blogEntries = await getCollection('blog'); + const blogEntries = await getCollection('posts'); return blogEntries.map(entry => ({ params: { slug: entry.slug }, props: { entry }, })); diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index 75401dc..77e0091 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -21,7 +21,7 @@ export async function GET(context) { const container = await AstroContainer.create({ renderers }); // Load the content collection entries to add to our RSS feed. - const posts = (await getCollection("blog")).sort((a, b) => + const posts = (await getCollection("posts")).sort((a, b) => // Sort by publication date descending. a.data.pubDate > b.data.pubDate ? -1 : 1 ); diff --git a/src/pages/search-index.json.js b/src/pages/search-index.json.js index 64fddd4..8b91cef 100644 --- a/src/pages/search-index.json.js +++ b/src/pages/search-index.json.js @@ -1,7 +1,7 @@ import { getCollection } from 'astro:content'; export async function GET() { - const posts = await getCollection('blog'); + const posts = await getCollection('posts'); const searchIndex = posts.map(post => ({ title: post.data.title, description: post.data.description,