2024-02-02 08:18:26 +01:00
|
|
|
import { error } from '@sveltejs/kit';
|
2024-08-25 21:35:59 +01:00
|
|
|
import type { MetaTagsProps } from 'svelte-meta-tags';
|
2024-02-02 08:18:26 +01:00
|
|
|
|
|
|
|
|
export async function load({ params }) {
|
|
|
|
|
try {
|
|
|
|
|
const blog = await import(`../../../blog/${params.slug}.md`);
|
|
|
|
|
|
2024-08-25 21:35:59 +01:00
|
|
|
const pageMetaTags = Object.freeze({
|
|
|
|
|
title: blog.metadata.title,
|
|
|
|
|
description: blog.metadata.description,
|
|
|
|
|
openGraph: {
|
|
|
|
|
title: blog.metadata.title,
|
|
|
|
|
description: blog.metadata.description,
|
|
|
|
|
images: [
|
|
|
|
|
{
|
|
|
|
|
url: blog.metadata.imageUrl,
|
|
|
|
|
alt: blog.metadata.title,
|
|
|
|
|
width: 280,
|
|
|
|
|
height: 200,
|
|
|
|
|
secureUrl: blog.metadata.imageUrl,
|
|
|
|
|
type: 'image/jpeg'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
twitter: {
|
|
|
|
|
handle: '@classroomio',
|
|
|
|
|
site: '@classroomio',
|
|
|
|
|
cardType: 'summary_large_image' as const,
|
|
|
|
|
title: blog.metadata.title,
|
|
|
|
|
description: blog.metadata.description,
|
|
|
|
|
image: blog.metadata.imageUrl,
|
|
|
|
|
imageAlt: `${blog.metadata.title} OG`
|
|
|
|
|
}
|
|
|
|
|
}) satisfies MetaTagsProps;
|
|
|
|
|
|
2024-02-02 08:18:26 +01:00
|
|
|
return {
|
|
|
|
|
content: blog.default,
|
|
|
|
|
meta: blog.metadata,
|
2024-08-25 21:35:59 +01:00
|
|
|
slug: params.slug,
|
|
|
|
|
pageMetaTags
|
2024-02-02 08:18:26 +01:00
|
|
|
};
|
|
|
|
|
} catch (e) {
|
|
|
|
|
throw error(404, `Could not find ${params.slug}`);
|
|
|
|
|
}
|
|
|
|
|
}
|