on master help sign in
pages: add terms-of-service
commitcaa0cfa90a689182c5ebbddb5dd40d5a5b96b8b9 authorMatilde Park <matilde@tlon.io> dateMon 12 Jul 2021, 17:58 (5 years ago) parent22289fa
2 files changed+23−1
lib/lib.js+2−1 pages/terms-of-service.js+21
lib/lib.js+2−1
@@ -11,6 +11,7 @@ const directories = {
1111 docs: join(process.cwd(), "content/docs"),
1212 grants: join(process.cwd(), "content/grants"),
1313 media: join(process.cwd(), "content/media"),
14+ "/": join(process.cwd(), "content"),
1415};
1516
1617export function getPostSlugs(key) {
@@ -49,7 +50,7 @@ export function getPostBySlug(slug, fields = [], key) {
4950 });
5051
5152 // 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, "") || "";
5354
5455 return items;
5556}
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+}