@@ -1,14 +1,22 @@
1+import { useRouter } from "next/router";
2+import { getPostBySlug, getAllPosts } from "../../lib/lib";
13import Head from "next/head";
24import Link from "next/link";
3−import { getPostBySlug } from "../../lib/lib";
45import Meta from "../../components/Meta";
5−import Markdown from "../../components/Markdown";
6+import ErrorPage from "../404";
67import Container from "../../components/Container";
8+import Markdown from "../../components/Markdown";
79import SingleColumn from "../../components/SingleColumn";
810import Section from "../../components/Section";
11+
912import { decode } from "html-entities";
1013
1114export default function GuidePage({ post, markdown }) {
15+ const router = useRouter();
16+ if (!router.isFallback && !post?.slug) {
17+ return <ErrorPage />;
18+ }
19+
1220 return (
1321 <Container>
1422 <Head>
@@ -34,7 +42,11 @@ export default function GuidePage({ post, markdown }) {
3442
3543//
3644export async function getStaticProps({ params }) {
37− const post = getPostBySlug("guide", ["title", "slug", "content"], "groups");
45+ const post = getPostBySlug(
46+ params.slug,
47+ ["title", "slug", "date", "description", "content", "extra"],
48+ "guides"
49+ );
3850
3951 const markdown = await Markdown({ post });
4052
@@ -42,3 +54,18 @@ export async function getStaticProps({ params }) {
4254 props: { post, markdown },
4355 };
4456}
57+
58+export async function getStaticPaths() {
59+ const posts = getAllPosts(["slug", "date"], "guides", "date");
60+
61+ return {
62+ paths: posts.map((post) => {
63+ return {
64+ params: {
65+ slug: post.slug,
66+ },
67+ };
68+ }),
69+ fallback: false,
70+ };
71+}