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