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