moved blog over to BlogPostLink data type to fix error 500 on page refresh
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
import Banner2 from "$lib/banner2.svelte";
|
||||
import Content from "$lib/viewport/content.svelte";
|
||||
import Gallery, { type GalleryEntry } from "$lib/lists/gallery.svelte";
|
||||
import { posts, type BlogPostDetails } from "./posts";
|
||||
import { posts, type BlogPostLink } from "./posts";
|
||||
|
||||
let entries: GalleryEntry[] = posts.entries().map(mapEntries).toArray();
|
||||
let entries: GalleryEntry[] = posts.map(mapEntries);
|
||||
|
||||
function mapEntries(m: [String, BlogPostDetails], index: number): GalleryEntry {
|
||||
function mapEntries(entry: BlogPostLink, index: number): GalleryEntry {
|
||||
return {
|
||||
title: `${m[1].title}`,
|
||||
subtitle: `#${posts.size - index} // ${m[1].date}, ${m[1].time}`,
|
||||
img: `/blog/${m[0]}/${m[1].banner}`,
|
||||
link: `/blog/${m[0]}/`,
|
||||
imgAlt: `Preview image for ${m[1].title}`,
|
||||
title: `${entry.post.title}`,
|
||||
subtitle: `#${posts.length - index} // ${entry.post.date}, ${entry.post.time}`,
|
||||
img: `/blog/${entry.key}/${entry.post.banner}`,
|
||||
link: `/blog/${entry.key}/`,
|
||||
imgAlt: `Preview image for ${entry.post.title}`,
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { posts, type BlogPostDetails } from '../../posts';
|
||||
import { posts, type BlogPostLink } 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 postValues = posts.find((v: BlogPostLink) => v.key == tag)?.post;
|
||||
const content = post.default;
|
||||
const title: string = postValues?.title ?? "";
|
||||
const date: string = postValues?.date ?? "";
|
||||
|
||||
@@ -15,7 +15,13 @@ export interface BlogPostDetails {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const posts = new Map<string, BlogPostDetails>([
|
||||
export interface BlogPostLink {
|
||||
key: string;
|
||||
post: BlogPostDetails;
|
||||
}
|
||||
|
||||
|
||||
export const posts: BlogPostLink[] = [
|
||||
// ["2026/0128", {
|
||||
// date: "2026-01-05",
|
||||
// time: "13:00",
|
||||
@@ -23,14 +29,17 @@ export const posts = new Map<string, BlogPostDetails>([
|
||||
// title: "Portsmouth Postmortem",
|
||||
// description: "",
|
||||
// }],
|
||||
["2026/0129", {
|
||||
{
|
||||
key: "2026/0129",
|
||||
post: {
|
||||
date: "2026-01-29",
|
||||
time: "16:42",
|
||||
banner: "girl.webp",
|
||||
title: "Limitations",
|
||||
description: "Something about how boundaries can foster creativity.",
|
||||
}],
|
||||
]);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// export function getDate(post: BlogPostDetails): string {
|
||||
// var s = [post.year, post.date.split()].join("");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import Banner2 from "$lib/banner2.svelte";
|
||||
import Content from "$lib/viewport/content.svelte";
|
||||
import { posts, type DevlogPost, type DevlogPostLink } from "./devlog/posts";
|
||||
import { posts, type DevlogPostLink } from "./devlog/posts";
|
||||
import Gallery, { type GalleryEntry } from "$lib/lists/gallery.svelte";
|
||||
|
||||
let entries = posts.map(mapEntries);
|
||||
let entries: GalleryEntry[] = posts.map(mapEntries);
|
||||
|
||||
function mapEntries(entry: DevlogPostLink, index: number): GalleryEntry {
|
||||
return {
|
||||
|
||||
@@ -4,7 +4,6 @@ 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 postValues = posts.find((v: DevlogPostLink) => v.key == tag)?.post;
|
||||
const content = post.default;
|
||||
const title: string = postValues?.title ?? "";
|
||||
|
||||
Reference in New Issue
Block a user