mixc
This commit is contained in:
1 parent
00edb9dfc2
commit
3865c45642
18 files changed
+439
-87
No files matched your search
@@ -1,11 +1,17 @@
|
||||
---
|
||||
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');
|
||||
return posts.map((post) => ({ params: { slug: post.id }, props: { post } }));
|
||||
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 } = Astro.props;
|
||||
const { post, mention } = Astro.props;
|
||||
---
|
||||
<Post lang="en" post={post} />
|
||||
{post ? <Post lang="en" post={post} /> : <Mention lang="en" mention={mention!} />}
|
||||
Reference in new issue
Block a user