mirror of
https://github.com/urbit/developers.urbit.org.git
synced 2024-09-11 13:55:59 +03:00
pages: add course permalink pages
This commit is contained in:
parent
04ce2fcb35
commit
d01de38f6a
50
pages/courses/[slug].js
Normal file
50
pages/courses/[slug].js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import BasicPage from "../../components/BasicPage";
|
||||||
|
import { Markdown, getPostBySlug, getAllPosts } from "@urbit/foundation-design-system";
|
||||||
|
|
||||||
|
export default function CoursePage({ post, markdown, search, index }) {
|
||||||
|
return (
|
||||||
|
<BasicPage
|
||||||
|
wide
|
||||||
|
post={post}
|
||||||
|
markdown={markdown}
|
||||||
|
search={search}
|
||||||
|
index={index}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getStaticProps({ params }) {
|
||||||
|
const post = getPostBySlug(
|
||||||
|
params.slug,
|
||||||
|
["title", "slug", "content", "extra"],
|
||||||
|
"courses"
|
||||||
|
);
|
||||||
|
|
||||||
|
let { index } = post?.extra || { index: null };
|
||||||
|
|
||||||
|
if (index === undefined) {
|
||||||
|
index = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const markdown = JSON.stringify(Markdown.parse({ post: { content: String.raw`${post.content}` } }));
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: { post, markdown, index },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function getStaticPaths() {
|
||||||
|
const posts = getAllPosts(["slug", "date"], "courses", "date");
|
||||||
|
|
||||||
|
return {
|
||||||
|
paths: posts.map((post) => {
|
||||||
|
return {
|
||||||
|
params: {
|
||||||
|
slug: post.slug,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
fallback: false,
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user