added structure for blog posts
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
</a>
|
||||
<a href="/projects">Projects</a>
|
||||
<a href="/projects/projectn5/devlog">Project N5</a>
|
||||
<a href="/">Blog</a>
|
||||
<a href="/blog">Blog</a>
|
||||
<a href="/about">About</a>
|
||||
{/snippet}
|
||||
|
||||
|
||||
1
src/routes/blog/+page.svelte
Normal file
1
src/routes/blog/+page.svelte
Normal file
@@ -0,0 +1 @@
|
||||
<!-- <a href="2026/0105/portsmouth">port</a> -->
|
||||
3
src/routes/blog/2026/0105.md
Normal file
3
src/routes/blog/2026/0105.md
Normal file
@@ -0,0 +1,3 @@
|
||||
test
|
||||
## Test
|
||||
working?
|
||||
27
src/routes/blog/[year]/[date]/+page.svelte
Normal file
27
src/routes/blog/[year]/[date]/+page.svelte
Normal file
@@ -0,0 +1,27 @@
|
||||
<script>
|
||||
import BannerTitleAlt from "$lib/banner-title-alt.svelte";
|
||||
import Content from "$lib/content.svelte";
|
||||
import TableOfContents from "$lib/table-of-contents.svelte";
|
||||
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{data.title} | denizk0461</title>
|
||||
<meta name="description" content="{data.description}">
|
||||
</svelte:head>
|
||||
|
||||
<BannerTitleAlt
|
||||
title="{data.title}"
|
||||
date="{data.date}"
|
||||
banner="preview.webp"
|
||||
bannerAlt="{""/*data.bannerAlt*/}"
|
||||
/>
|
||||
|
||||
<Content useContentWidth>
|
||||
|
||||
<TableOfContents disableStickyScrolling />
|
||||
|
||||
<svelte:component this={data.content} />
|
||||
|
||||
</Content>
|
||||
22
src/routes/blog/[year]/[date]/+page.ts
Normal file
22
src/routes/blog/[year]/[date]/+page.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { posts, type BlogPostDetails } from '../../posts';
|
||||
|
||||
export async function load({ params }) {
|
||||
const post = await import(`../../${params.year}/${params.date}.md`);
|
||||
|
||||
const tag: string = `${params.year}/${params.date}`;
|
||||
const postValues = posts.get(tag);
|
||||
const content = post.default;
|
||||
const title: string = postValues?.fullTitle ?? "";
|
||||
const date: string = postValues?.date ?? "";
|
||||
// const bannerAlt: string = postValues?.bannerAlt ?? "";
|
||||
const description: string = postValues?.description ?? "";
|
||||
|
||||
return {
|
||||
content,
|
||||
title,
|
||||
date,
|
||||
tag,
|
||||
// bannerAlt,
|
||||
description,
|
||||
};
|
||||
}
|
||||
29
src/routes/blog/posts.ts
Normal file
29
src/routes/blog/posts.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export interface BlogPostDetails {
|
||||
date: string;
|
||||
|
||||
/**
|
||||
* Short title to be used in URL.
|
||||
*/
|
||||
shortTitle: string;
|
||||
fullTitle: string;
|
||||
|
||||
/**
|
||||
* Description to be used in page's metadata.
|
||||
*/
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const posts = new Map<string, BlogPostDetails>([
|
||||
["2026/0105", {
|
||||
date: "2026-01-05",
|
||||
shortTitle: "portsmouth",
|
||||
fullTitle: "Portsmouth Postmortem",
|
||||
description: "",
|
||||
}],
|
||||
]);
|
||||
|
||||
// export function getDate(post: BlogPostDetails): string {
|
||||
// var s = [post.year, post.date.split()].join("");
|
||||
// s.
|
||||
// return "";
|
||||
// }
|
||||
BIN
static/blog/2026/0105/preview.webp
Normal file
BIN
static/blog/2026/0105/preview.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
Reference in New Issue
Block a user