41 lines
1000 B
Plaintext
41 lines
1000 B
Plaintext
---
|
|
import { SITE, BLOG } from '~/config.mjs';
|
|
|
|
import Layout from '~/layouts/PageLayout.astro';
|
|
import SinglePost from '~/components/blog/SinglePost.astro';
|
|
|
|
import { getCanonical, getPermalink, cleanSlug, POST_BASE } from '~/utils/permalinks';
|
|
import { fetchPosts } from '~/utils/posts';
|
|
import { findImage } from '~/utils/images';
|
|
|
|
export async function getStaticPaths() {
|
|
if (BLOG?.disabled || BLOG?.post?.disabled) return [];
|
|
|
|
const posts = await fetchPosts();
|
|
|
|
return posts.map((post) => ({
|
|
params: {
|
|
slug: cleanSlug(post.slug),
|
|
blog: POST_BASE || undefined,
|
|
},
|
|
props: { post },
|
|
}));
|
|
}
|
|
|
|
const { post } = Astro.props;
|
|
const url = getCanonical(getPermalink(post.slug, 'post'));
|
|
|
|
const meta = {
|
|
title: `${post.title} — ${SITE.name}`,
|
|
description: post.description,
|
|
canonical: post.canonical || url,
|
|
image: await findImage(post.image),
|
|
ogTitle: post.title,
|
|
ogType: 'article',
|
|
};
|
|
---
|
|
|
|
<Layout {meta}>
|
|
<SinglePost post={{ ...post, image: meta.image }} url={url} />
|
|
</Layout>
|