get routing working, add index for poetry, list first 6 poems on index, let each take you to their page with the poem's content
This commit is contained in:
18
src/routes/(app)/poetry/[slug]/+page.ts
Normal file
18
src/routes/(app)/poetry/[slug]/+page.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { Metadata } from '$lib/utils/index.js';
|
||||
|
||||
export async function load({ params }) {
|
||||
const post = await import(`../../../../posts/poetry/${params.slug}.md`);
|
||||
const { title, date, categories } = post.metadata as Metadata;
|
||||
const Content = post.default;
|
||||
const parsedDate = new Date(date.slice(0, date.length - 6));
|
||||
const validDate = `${
|
||||
parsedDate.getMonth() + 1
|
||||
}/${parsedDate.getDate()}/${parsedDate.getFullYear()}`;
|
||||
|
||||
return {
|
||||
Content,
|
||||
title,
|
||||
date: validDate,
|
||||
categories
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user