File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ title : " Test post foobar"
3+ description : " kekw"
4+ keywords : []
5+
6+ hidetoc : true
7+ ---
8+
9+ barbaz
Original file line number Diff line number Diff line change 1+ import { glob } from "astro/loaders" ;
2+ import { z , defineCollection } from "astro:content" ;
3+
4+ const blogPosts = defineCollection ( {
5+ loader : glob ( { pattern : "**/[^_]*.md" , base : "./src/blog-posts" } ) ,
6+ schema : z . object ( {
7+ title : z . string ( ) ,
8+ description : z . string ( ) ,
9+ keywords : z . array ( z . string ( ) ) ,
10+
11+ hidetoc : z . boolean ( ) . optional ( ) ,
12+ wip : z . boolean ( ) . optional ( ) ,
13+ } ) ,
14+ } ) ;
15+
16+ export const collections = {
17+ blogPosts,
18+ } ;
Original file line number Diff line number Diff line change @@ -53,3 +53,14 @@ export function isViteGlobObject(obj: unknown): obj is ViteGlobObject {
5353
5454 return true ;
5555}
56+
57+ /*
58+ * Workaround for casting arbitrary objects to { [key: string]: unknown; }
59+ */
60+ //export function toObjMappingUnknowns(obj: unknown): {[key: string]: unknown;} {
61+ // if (!obj || typeof obj !== "object") {
62+ // throw new Error("Failed to cast object to { [key: string]: unknown; }");
63+ // }
64+ // return obj as {[key: string]: unknown;};
65+ //}
66+
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ function makeFullTree(): PageTree {
6767 "/src/pages/**/*.mdx" ,
6868 "!/src/pages/**/_*" ,
6969 "!/src/pages/**/_*/**/*" ,
70+ "!/src/pages/**/\\[*.astro" ,
7071 ] , { eager : true } ) ;
7172
7273 const reprocessedResult = Object . entries ( globResult ) . map ( ( [ k , v ] ) => {
Original file line number Diff line number Diff line change 1+ ---
2+ import {getCollection , render } from " astro:content" ;
3+ import Layout from " @layouts/GeneralLayout.astro" ;
4+
5+ import {makeFrontmatter } from " @helpers/frontmatter" ;
6+
7+ export async function getStaticPaths() {
8+ const posts = await getCollection (" blogPosts" );
9+ return posts .map (post => ({
10+ params: {slug: post .id },
11+ props: {post },
12+ }));
13+ }
14+
15+ const {post} = Astro .props ;
16+ const {Content} = await render (post );
17+
18+ const frontmatter = makeFrontmatter ({... post .data });
19+ ---
20+
21+ <Layout {... frontmatter }>
22+ <Content />
23+ </Layout >
Original file line number Diff line number Diff line change 11---
22import Layout from " @layouts/BaseLayout.astro" ;
3+ import {getCollection } from " astro:content" ;
4+
35import {fm } from " @helpers/frontmatter" ;
46
7+ const allPosts = await getCollection (" blogPosts" );
8+
59export const frontmatter = fm ({
610 title: " Sim's Blog" ,
711 description: " Sim's blog." ,
@@ -15,5 +19,13 @@ export const frontmatter = fm({
1519
1620 <p ><em >This is an early WIP focused on experimenting with ways to manage my blog posts before migrating <a href =" https://blog.simshadows.com/" >my old blog</a > to this website.</em ></p >
1721
22+ <ul >
23+ {
24+ allPosts .map ((post ) => (
25+ <li ><a href = { ` /blog/${post .id }/ ` } >{ post .data .title } </a ></li >
26+ ))
27+ }
28+ </ul >
29+
1830</Layout >
1931
You can’t perform that action at this time.
0 commit comments