on master help sign in
pages: add terms-of-service
caa0cfaMatilde Park
lib/lib.js+2−1
@@ -11,6 +11,7 @@ const directories = {
11 docs: join(process.cwd(), "content/docs"),
11 docs: join(process.cwd(), "content/docs"),
12 grants: join(process.cwd(), "content/grants"),
12 grants: join(process.cwd(), "content/grants"),
13 media: join(process.cwd(), "content/media"),
13 media: join(process.cwd(), "content/media"),
14+ "/": join(process.cwd(), "content"),
14};
15};
15
16
16export function getPostSlugs(key) {
17export function getPostSlugs(key) {
@@ -49,7 +50,7 @@ export function getPostBySlug(slug, fields = [], key) {
49 });
50 });
50
51
51 // NB Gavin: This could be removed if the TOML engine returned a JSON date (string) instead of a JS Date object. The YAML engine did this parsing by default.
52 // NB Gavin: This could be removed if the TOML engine returned a JSON date (string) instead of a JS Date object. The YAML engine did this parsing by default.
52− items.date = JSON.stringify(items.date).replace(/\"/g, "");
53+ items.date = JSON.stringify(items?.date)?.replace(/\"/g, "") || "";
53
54
54 return items;
55 return items;
55}
56}
pages/terms-of-service.jsnew file+21
@@ -0,0 +1,21 @@
1+import { getPostBySlug } from "../lib/lib";
2+import BasicPage from "../components/BasicPage";
3+import Markdown from "../components/Markdown";
4+
5+export default function Post({ post, markdown, search }) {
6+ return <BasicPage post={post} markdown={markdown} search={search} />;
7+}
8+
9+export async function getStaticProps({ params }) {
10+ const post = getPostBySlug(
11+ "/terms-of-use",
12+ ["title", "slug", "content"],
13+ "/"
14+ );
15+
16+ const markdown = await Markdown({ post });
17+
18+ return {
19+ props: { post, markdown },
20+ };
21+}