feat: custom pages support
This commit is contained in:
parent
7e5f8ce06f
commit
9411ec22c1
3 changed files with 33 additions and 0 deletions
7
src/content/pages/_schemas.ts
Normal file
7
src/content/pages/_schemas.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { z } from 'astro:content';
|
||||||
|
|
||||||
|
export const pages = z.object({
|
||||||
|
title: z.string(),
|
||||||
|
description: z.string(),
|
||||||
|
heroImage: z.string().optional()
|
||||||
|
});
|
5
src/content/pages/test.md
Normal file
5
src/content/pages/test.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: 'Test Page'
|
||||||
|
description: 'This is a test page'
|
||||||
|
---
|
||||||
|
testestestest
|
21
src/pages/[...slug].astro
Normal file
21
src/pages/[...slug].astro
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
import Layout from '../layouts/Layout.astro';
|
||||||
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
|
export async function getStaticPaths() {
|
||||||
|
const pageEntries = await getCollection('pages');
|
||||||
|
return pageEntries.map(entry => ({
|
||||||
|
params: { slug: entry.slug }, props: { entry },
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const { entry } = Astro.props;
|
||||||
|
const { Content } = await entry.render();
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<Layout title={`${entry.data.title} | Terminal Blog`} path={`/var/log/${entry.slug}`}>
|
||||||
|
<h1 class="post-title">{entry.data.title}</h1>
|
||||||
|
<div class="post-content">
|
||||||
|
<Content/>
|
||||||
|
</div>
|
||||||
|
</Layout>
|
Loading…
Add table
Add a link
Reference in a new issue