18 lines
884 B
Plaintext
18 lines
884 B
Plaintext
---
|
|
import { getCollection } from 'astro:content';
|
|
import Post from '../_Post.astro';
|
|
import Mention from '../_Mention.astro';
|
|
|
|
/* Essays and mentions share /insights/<slug>; a slug used by both would be a defect. */
|
|
export async function getStaticPaths() {
|
|
const posts = (await getCollection('insights')).map((post) => ({ params: { slug: post.id }, props: { post } }));
|
|
const mentions = (await getCollection('mentions')).map((mention) => ({ params: { slug: mention.id }, props: { mention } }));
|
|
const taken = new Set(posts.map((p) => p.params.slug));
|
|
const clash = mentions.find((m) => taken.has(m.params.slug));
|
|
if (clash) throw new Error(`Insights slug used by an essay and a mention: ${clash.params.slug}`);
|
|
return [...posts, ...mentions];
|
|
}
|
|
const { post, mention } = Astro.props;
|
|
---
|
|
{post ? <Post lang="en" post={post} /> : <Mention lang="en" mention={mention!} />}
|