on master help sign in
components, pages: split markdown parsing into server-side
commit35af151fffd96c7c484fa399c62c9ce4690d3eeb authorMatilde Park <matilde.park@urbit.org> dateTue 7 Jun 2022, 15:00 (4 years ago) parent381e97b
24 files changed+132−77
components/BasicPage.js+2−3 components/GrantProgramOverview.js+2−1 components/PageWithIndex.js+2−2 components/gateway/Description.js+3−2 pages/applications/[[...application]].js+5−2 pages/audits.js+5−2 pages/bitcoin-wallet.js+6−3 pages/blog/[slug].js+11−4 pages/coinmarketcap.js+6−3 pages/community/[[...slug]].js+6−4 pages/docs/[[...slug]].js+5−4 pages/events/[slug].js+12−4 pages/faq.js+5−3 pages/getting-started/[[...slug]].js+6−4 pages/grants/[slug].js+5−4 pages/groups/[[...group]].js+6−4 pages/ids/[id].js+6−3 pages/media/[slug].js+6−4 pages/privacy.js+6−3 pages/terms-of-service.js+5−3 pages/understanding-urbit/[[...slug]].js+6−4 pages/updates/[slug].js+5−4 pages/using/[[...slug]].js+6−4 pages/voting-instructions.js+5−3
components/BasicPage.js+2−3
@@ -7,10 +7,9 @@ import Header from "./Header";
77import Footer from "./Footer";
88import SingleColumn from "./SingleColumn";
99import Section from "./Section";
10−import { decode } from "html-entities";
1110import Markdown from "./Markdown";
1211
13−export default function BasicPage({ post, search }) {
12+export default function BasicPage({ post, markdown, search }) {
1413 const router = useRouter();
1514 if (!router.isFallback && !post?.slug) {
1615 return <ErrorPage />;
@@ -27,7 +26,7 @@ export default function BasicPage({ post, search }) {
2726 <h1>{post.title}</h1>
2827 </Section>
2928 <Section narrow className="markdown">
30− <Markdown post={post} />
29+ <Markdown content={JSON.parse(markdown)} />
3130 </Section>
3231 </SingleColumn>
3332 <Footer />
components/GrantProgramOverview.js+2−1
@@ -14,6 +14,7 @@ import Markdown from "./Markdown";
1414
1515export default function GrantProgramOverview({
1616 post,
17+ markdown,
1718 search,
1819 program,
1920 actionLink,
@@ -45,7 +46,7 @@ export default function GrantProgramOverview({
4546 </Link>
4647 </Section>
4748 <Section narrow short className="markdown">
48− <Markdown post={post} />
49+ <Markdown content={JSON.parse(markdown)} />
4950 </Section>
5051 </SingleColumn>
5152 <Footer />
components/PageWithIndex.js+2−2
@@ -10,7 +10,7 @@ import Section from "./Section";
1010import Markdown from "../components/Markdown";
1111import { TableOfContents } from "./TableOfContents";
1212
13−export default function PageWithIndex({ post, search }) {
13+export default function PageWithIndex({ post, markdown, search }) {
1414 const router = useRouter();
1515 if (!router.isFallback && !post?.slug) {
1616 return <ErrorPage />;
@@ -29,7 +29,7 @@ export default function PageWithIndex({ post, search }) {
2929 <Section narrow>
3030 <div className="flex sidebar">
3131 <div className="markdown max-w-prose">
32− <Markdown post={post} />
32+ <Markdown content={JSON.parse(markdown)} />
3333 </div>
3434 <TableOfContents />
3535 </div>
components/gateway/Description.js+3−2
@@ -1,4 +1,3 @@
1−import { decode } from "html-entities";
21import Markdown from "../Markdown";
32
43const Description = ({ description, fallback, markdown }) => {
@@ -7,7 +6,9 @@ const Description = ({ description, fallback, markdown }) => {
76 <div className="flex flex-col space-y-4">
87 <p className="font-bold text-wall-400">Description</p>
98 {markdown ? (
10− <Markdown post={{ content: markdown }} />
9+ <div className="markdown">
10+ <Markdown content={JSON.parse(markdown)} />
11+ </div>
1112 ) : (
1213 <p>{description}</p>
1314 )}
pages/applications/[[...application]].js+5−2
@@ -7,6 +7,7 @@ import Container from "../../components/Container";
77import SingleColumn from "../../components/SingleColumn";
88import Section from "../../components/Section";
99import ob from "urbit-ob";
10+import { MarkdownParse } from "../../components/Markdown";
1011import GatewayHeader from "../../components/gateway/GatewayHeader";
1112import Gateway404 from "../../components/gateway/Gateway404";
1213import MetadataBlock from "../../components/gateway/MetadataBlock";
@@ -94,7 +95,7 @@ const ApplicationPage = ({ data, content, params }) => {
9495 <Description
9596 description={data.description}
9697 fallback="An application on Urbit."
97− markdown={content}
98+ markdown={markdown}
9899 />
99100 <hr className="text-wall-200" />
100101 <div className="flex flex-col space-y-6">
@@ -145,6 +146,8 @@ export const getServerSideProps = async ({ params, res }) => {
145146 )
146147 ) || { data: {}, content: "" };
147148
149+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
150+
148151 if (!data.title) {
149152 data = {
150153 title: params.application?.join("/"),
@@ -155,7 +158,7 @@ export const getServerSideProps = async ({ params, res }) => {
155158 return {
156159 props: {
157160 data,
158− content,
161+ markdown,
159162 params,
160163 },
161164 };
pages/audits.js+5−2
@@ -1,14 +1,17 @@
11import { getPostBySlug } from "../lib/lib";
22import BasicPage from "../components/BasicPage";
3+import { MarkdownParse } from "../components/Markdown";
34
45export default function Post({ post, search }) {
5− return <BasicPage post={post} search={search} />;
6+ return <BasicPage post={post} markdown={markdown} search={search} />;
67}
78
89export async function getStaticProps() {
910 const post = getPostBySlug("/audits", ["title", "slug", "content"], "/");
1011
12+ const markdown = JSON.stringify(MarkdownParse({ post }));
13+
1114 return {
12− props: { post },
15+ props: { post, markdown },
1316 };
1417}
pages/bitcoin-wallet.js+6−3
@@ -1,8 +1,9 @@
11import { getPostBySlug } from "../lib/lib";
22import BasicPage from "../components/BasicPage";
3+import { MarkdownParse } from "../components/Markdown";
34
4−export default function Post({ post, search }) {
5− return <BasicPage post={post} search={search} />;
5+export default function Post({ post, markdown, search }) {
6+ return <BasicPage post={post} markdown={markdown} search={search} />;
67}
78
89export async function getStaticProps() {
@@ -12,7 +13,9 @@ export async function getStaticProps() {
1213 "/"
1314 );
1415
16+ const markdown = JSON.stringify(MarkdownParse({ post }));
17+
1518 return {
16− props: { post },
19+ props: { post, markdown },
1720 };
1821}
pages/blog/[slug].js+11−4
@@ -19,9 +19,15 @@ import Section from "../../components/Section";
1919import Contact from "../../components/Contact";
2020import PostPreview from "../../components/PostPreview";
2121import TwoUp from "../../components/TwoUp";
22−import Markdown from "../../components/Markdown";
22+import Markdown, { MarkdownParse } from "../../components/Markdown";
2323
24−export default function Post({ post, nextPost, previousPost, search }) {
24+export default function Post({
25+ post,
26+ markdown,
27+ nextPost,
28+ previousPost,
29+ search,
30+}) {
2531 const router = useRouter();
2632 if (!router.isFallback && !post?.slug) {
2733 return <ErrorPage />;
@@ -53,7 +59,7 @@ export default function Post({ post, nextPost, previousPost, search }) {
5359 <div className="text-wall-500 type-sub">{formatDate(date)}</div>
5460 </Section>
5561 <Section short narrow className="markdown">
56− <Markdown post={post} />
62+ <Markdown content={JSON.parse(markdown)} />
5763 </Section>
5864 <Section narrow>
5965 <Contact />
@@ -96,8 +102,9 @@ export async function getStaticProps({ params }) {
96102 "blog"
97103 );
98104
105+ const markdown = JSON.stringify(MarkdownParse({ post }));
99106 return {
100− props: { post, nextPost, previousPost },
107+ props: { post, markdown, nextPost, previousPost },
101108 };
102109}
103110
pages/coinmarketcap.js+6−3
@@ -1,8 +1,9 @@
11import { getPostBySlug } from "../lib/lib";
22import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
34
4−export default function Post({ post, search }) {
5− return <PageWithIndex post={post} search={search} />;
5+export default function Post({ post, markdown, search }) {
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
67}
78
89export async function getStaticProps() {
@@ -12,7 +13,9 @@ export async function getStaticProps() {
1213 "/"
1314 );
1415
16+ const markdown = JSON.stringify(MarkdownParse({ post }));
17+
1518 return {
16− props: { post },
19+ props: { post, markdown },
1720 };
1821}
pages/community/[[...slug]].js+6−4
@@ -5,7 +5,7 @@ import classnames from "classnames";
55import { join } from "path";
66import { getPage } from "../../lib/lib";
77import Meta from "../../components/Meta";
8−import Markdown from "../../components/Markdown";
8+import Markdown, { MarkdownParse } from "../../components/Markdown";
99import ContentArea from "../../components/ContentArea";
1010import Sidebar from "../../components/Sidebar";
1111import communityTree from "../../cache/community.json";
@@ -58,7 +58,7 @@ const pageTree = (thisLink, tree, level = 0) => {
5858 );
5959};
6060
61−export default function UsingLayout({ posts, data, params, search, content }) {
61+export default function UsingLayout({ posts, data, markdown, params, search }) {
6262 return (
6363 <>
6464 <Head>
@@ -77,7 +77,7 @@ export default function UsingLayout({ posts, data, params, search, content }) {
7777 params={params}
7878 >
7979 <div className="markdown">
80− <Markdown post={{ content: content }} />
80+ <Markdown content={JSON.parse(markdown)} />
8181 </div>
8282 </ContentArea>
8383 </div>
@@ -92,7 +92,9 @@ export async function getStaticProps({ params }) {
9292 join(process.cwd(), "content/community", params.slug?.join("/") || "/")
9393 );
9494
95− return { props: { posts, data, content, params } };
95+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
96+
97+ return { props: { posts, data, markdown, params } };
9698}
9799
98100export async function getStaticPaths() {
pages/docs/[[...slug]].js+5−4
@@ -7,7 +7,7 @@ import { join } from "path";
77import { getPreviousPost, getNextPost, getPage } from "../../lib/lib";
88import Meta from "../../components/Meta";
99import Pagination from "../../components/Pagination";
10−import Markdown from "../../components/Markdown";
10+import Markdown, { MarkdownParse } from "../../components/Markdown";
1111import ContentArea from "../../components/ContentArea";
1212import Sidebar from "../../components/Sidebar";
1313import docsPageTree from "../../cache/docs.json";
@@ -103,7 +103,7 @@ export default function DocsLayout({
103103 data,
104104 params,
105105 search,
106− content,
106+ markdown,
107107 previousPost,
108108 nextPost,
109109}) {
@@ -144,7 +144,7 @@ export default function DocsLayout({
144144 params={params}
145145 >
146146 <div className="markdown technical">
147− <Markdown post={{ content: content }} />
147+ <Markdown content={JSON.parse(markdown)} />
148148 </div>
149149 <div className="flex justify-between mt-16">
150150 {previousPost === null ? (
@@ -208,7 +208,8 @@ export async function getStaticProps({ params }) {
208208 "weight"
209209 ) || null;
210210
211− return { props: { posts, data, content, previousPost, nextPost, params } };
211+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
212+ return { props: { posts, data, markdown, previousPost, nextPost, params } };
212213}
213214
214215export async function getStaticPaths() {
pages/events/[slug].js+12−4
@@ -10,7 +10,7 @@ import {
1010import Head from "next/head";
1111import Meta from "../../components/Meta";
1212import Container from "../../components/Container";
13−import Markdown from "../../components/Markdown";
13+import Markdown, { MarkdownParse } from "../../components/Markdown";
1414import Header from "../../components/Header";
1515import Footer from "../../components/Footer";
1616import SingleColumn from "../../components/SingleColumn";
@@ -27,7 +27,13 @@ import {
2727} from "../../components/Snippets";
2828import { eventKeys } from "../../lib/constants";
2929
30−export default function Event({ event, nextEvent, previousEvent, search }) {
30+export default function Event({
31+ event,
32+ markdown,
33+ nextEvent,
34+ previousEvent,
35+ search,
36+}) {
3137 const starts = generateDisplayDate(event.starts, event.timezone);
3238 const ends = generateDisplayDate(event.ends, event.timezone);
3339
@@ -110,7 +116,7 @@ export default function Event({ event, nextEvent, previousEvent, search }) {
110116 ) : null}
111117
112118 <Section short narrow className="markdown">
113− <Markdown post={event} />
119+ <Markdown content={JSON.parse(markdown)} />
114120 </Section>
115121 <Section narrow>
116122 <Contact />
@@ -147,8 +153,10 @@ export async function getStaticProps({ params }) {
147153
148154 const event = getPostBySlug(params.slug, eventKeys, "events");
149155
156+ const markdown = JSON.stringify(MarkdownParse({ post: event }));
157+
150158 return {
151− props: { event, nextEvent, previousEvent },
159+ props: { event, markdown, nextEvent, previousEvent },
152160 };
153161}
154162
pages/faq.js+5−3
@@ -1,14 +1,16 @@
11import { getPostBySlug } from "../lib/lib";
22import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
34
4−export default function Post({ post, search }) {
5− return <PageWithIndex post={post} search={search} />;
5+export default function Post({ post, markdown, search }) {
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
67}
78
89export async function getStaticProps() {
910 const post = getPostBySlug("/faq", ["title", "slug", "content"], "/");
1011
12+ const markdown = JSON.stringify(MarkdownParse({ post }));
1113 return {
12− props: { post },
14+ props: { post, markdown },
1315 };
1416}
pages/getting-started/[[...slug]].js+6−4
@@ -5,12 +5,12 @@ import { useRouter } from "next/router";
55import classnames from "classnames";
66import { join } from "path";
77import { getPage } from "../../lib/lib";
8−import Markdown from "../../components/Markdown";
8+import Markdown, { MarkdownParse } from "../../components/Markdown";
99import ContentArea from "../../components/ContentArea";
1010import Sidebar from "../../components/Sidebar";
1111import GettingStartedTree from "../../cache/getting-started.json";
1212
13−export default function UsingLayout({ posts, data, params, search, content }) {
13+export default function UsingLayout({ posts, data, params, search, markdown }) {
1414 const router = useRouter();
1515
1616 const select = (href) => {
@@ -86,7 +86,7 @@ export default function UsingLayout({ posts, data, params, search, content }) {
8686 disableToC
8787 >
8888 <div className="markdown">
89− <Markdown post={{ content: content }} />
89+ <Markdown content={JSON.parse(markdown)} />
9090 </div>
9191 {!params?.slug && <LaunchCards />}
9292 </ContentArea>
@@ -290,7 +290,9 @@ export async function getStaticProps({ params }) {
290290 )
291291 );
292292
293− return { props: { posts, data, content, params } };
293+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
294+
295+ return { props: { posts, data, markdown, params } };
294296}
295297
296298export async function getStaticPaths() {
pages/grants/[slug].js+5−4
@@ -6,7 +6,7 @@ import Meta from "../../components/Meta";
66import classnames from "classnames";
77import ErrorPage from "../404";
88import Container from "../../components/Container";
9−import Markdown from "../../components/Markdown";
9+import Markdown, { MarkdownParse } from "../../components/Markdown";
1010import Header from "../../components/Header";
1111import Footer from "../../components/Footer";
1212import SingleColumn from "../../components/SingleColumn";
@@ -14,7 +14,7 @@ import ob from "urbit-ob";
1414import Section from "../../components/Section";
1515import { DateTime } from "luxon";
1616
17−export default function Grant({ post, search }) {
17+export default function Grant({ post, markdown, search }) {
1818 const router = useRouter();
1919 if (!router.isFallback && !post?.slug) {
2020 return <ErrorPage />;
@@ -102,7 +102,7 @@ export default function Grant({ post, search }) {
102102 </div>
103103 </Section>
104104 <Section narrow className="markdown">
105− <Markdown post={post} />
105+ <Markdown content={JSON.parse(markdown)} />
106106 </Section>
107107 {canApply && (
108108 <a
@@ -127,8 +127,9 @@ export async function getStaticProps({ params }) {
127127 "grants"
128128 );
129129
130+ const markdown = JSON.stringify(MarkdownParse({ post }));
130131 return {
131− props: { post },
132+ props: { post, markdown },
132133 };
133134}
134135
pages/groups/[[...group]].js+6−4
@@ -7,14 +7,14 @@ import Container from "../../components/Container";
77import SingleColumn from "../../components/SingleColumn";
88import Section from "../../components/Section";
99import ob from "urbit-ob";
10−import Markdown from "../../components/Markdown";
10+import { MarkdownParse } from "../../components/Markdown";
1111import GatewayHeader from "../../components/gateway/GatewayHeader";
1212import Gateway404 from "../../components/gateway/Gateway404";
1313import MetadataBlock from "../../components/gateway/MetadataBlock";
1414import MetadataLink from "../../components/gateway/MetadataLink";
1515import Description from "../../components/gateway/Description";
1616
17−const GroupPage = ({ data, content, params }) => {
17+const GroupPage = ({ data, markdown, params }) => {
1818 const { group } = params;
1919 if (!ob.isValidPatp(group?.[0] || "")) {
2020 return <Gateway404 type="group" />;
@@ -89,7 +89,7 @@ const GroupPage = ({ data, content, params }) => {
8989 <Description
9090 description={data.description}
9191 fallback="A group on Urbit."
92− markdown={content}
92+ markdown={markdown}
9393 />
9494 <hr className="text-wall-200" />
9595 <div className="flex flex-col space-y-6">
@@ -133,6 +133,8 @@ export const getServerSideProps = async ({ params, res }) => {
133133 join(process.cwd(), "content/groups", params.group?.join("/") || "/")
134134 ) || { data: {}, content: "" };
135135
136+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
137+
136138 if (!data.title) {
137139 data = { title: params.group?.join("/"), description: "A group on Urbit." };
138140 }
@@ -140,7 +142,7 @@ export const getServerSideProps = async ({ params, res }) => {
140142 return {
141143 props: {
142144 data,
143− content,
145+ markdown,
144146 params,
145147 },
146148 };
pages/ids/[id].js+6−3
@@ -13,8 +13,9 @@ import MetadataBlock from "../../components/gateway/MetadataBlock";
1313import MetadataLink from "../../components/gateway/MetadataLink";
1414import Description from "../../components/gateway/Description";
1515import axios from "axios";
16+import { MarkdownParse } from "../../components/Markdown";
1617
17−const IdPage = ({ data, content, applications, groups, network, params }) => {
18+const IdPage = ({ data, markdown, applications, groups, network, params }) => {
1819 let { id } = params;
1920 id = `~${deSig(id)}`;
2021 if (!ob.isValidPatp(id) || id.length > 14) {
@@ -109,7 +110,7 @@ const IdPage = ({ data, content, applications, groups, network, params }) => {
109110 <Description
110111 description={data.description}
111112 fallback="An Urbit ID."
112− markdown={content}
113+ markdown={markdown}
113114 />
114115 <a
115116 className="flex items-center"
@@ -206,6 +207,8 @@ export const getServerSideProps = async ({ params, res }) => {
206207 join(process.cwd(), "content/ids/", id.slice(1))
207208 ) || { data: {}, content: "" };
208209
210+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
211+
209212 const applications = getAllPosts(
210213 ["title", "slug", "image", "bgColor"],
211214 `applications/${params.id}`
@@ -229,7 +232,7 @@ export const getServerSideProps = async ({ params, res }) => {
229232 data,
230233 applications,
231234 groups,
232− content,
235+ markdown,
233236 network,
234237 params,
235238 },
pages/media/[slug].js+6−4
@@ -10,14 +10,14 @@ import Link from "next/link";
1010import Meta from "../../components/Meta";
1111import ErrorPage from "../404";
1212import Container from "../../components/Container";
13−import Markdown from "../../components/Markdown";
13+import Markdown, { MarkdownParse } from "../../components/Markdown";
1414import Header from "../../components/Header";
1515import Footer from "../../components/Footer";
1616import SingleColumn from "../../components/SingleColumn";
1717import Contact from "../../components/Contact";
1818import Section from "../../components/Section";
1919
20−export default function MediaPage({ post, search }) {
20+export default function MediaPage({ post, markdown, search }) {
2121 const router = useRouter();
2222 if (!router.isFallback && !post?.slug) {
2323 return <ErrorPage />;
@@ -71,7 +71,7 @@ export default function MediaPage({ post, search }) {
7171 ) : null}
7272 </Section>
7373 <Section narrow className="markdown">
74− <Markdown post={post} />
74+ <Markdown content={JSON.parse(markdown)} />
7575 </Section>
7676 <Section narrow>
7777 <Contact />
@@ -90,8 +90,10 @@ export async function getStaticProps({ params }) {
9090 "media"
9191 );
9292
93+ const markdown = JSON.stringify(MarkdownParse({ post }));
94+
9395 return {
94− props: { post },
96+ props: { post, markdown },
9597 };
9698}
9799
pages/privacy.js+6−3
@@ -1,14 +1,17 @@
11import { getPostBySlug } from "../lib/lib";
22import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
34
4−export default function Post({ post, search }) {
5− return <PageWithIndex post={post} search={search} />;
5+export default function Post({ post, markdown, search }) {
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
67}
78
89export async function getStaticProps() {
910 const post = getPostBySlug("/privacy", ["title", "slug", "content"], "/");
1011
12+ const markdown = JSON.stringify(MarkdownParse({ post }));
13+
1114 return {
12− props: { post },
15+ props: { post, markdown },
1316 };
1417}
pages/terms-of-service.js+5−3
@@ -1,8 +1,9 @@
11import { getPostBySlug } from "../lib/lib";
22import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
34
4−export default function Post({ post, search }) {
5− return <PageWithIndex post={post} search={search} />;
5+export default function Post({ post, markdown, search }) {
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
67}
78
89export async function getStaticProps() {
@@ -12,7 +13,8 @@ export async function getStaticProps() {
1213 "/"
1314 );
1415
16+ const markdown = JSON.stringify(MarkdownParse({ post }));
1517 return {
16− props: { post },
18+ props: { post, markdown },
1719 };
1820}
pages/understanding-urbit/[[...slug]].js+6−4
@@ -5,7 +5,7 @@ import { useRouter } from "next/router";
55import classnames from "classnames";
66import { join } from "path";
77import { getPage, getPreviousPost, getNextPost } from "../../lib/lib";
8−import Markdown from "../../components/Markdown";
8+import Markdown, { MarkdownParse } from "../../components/Markdown";
99import ContentArea from "../../components/ContentArea";
1010import Sidebar from "../../components/Sidebar";
1111import Pagination from "../../components/Pagination";
@@ -64,7 +64,7 @@ export default function UnderstandingLayout({
6464 data,
6565 params,
6666 search,
67− content,
67+ markdown,
6868 previousPost,
6969 nextPost,
7070}) {
@@ -101,9 +101,10 @@ export default function UnderstandingLayout({
101101 search={search}
102102 section={"Understanding Urbit"}
103103 params={params}
104+ disableToC
104105 >
105106 <div className="markdown">
106− <Markdown post={{ content: content }} />
107+ <Markdown content={JSON.parse(markdown)} />
107108 </div>
108109 <div className="flex justify-between mt-16">
109110 {previousPost === null ? (
@@ -151,6 +152,7 @@ export async function getStaticProps({ params }) {
151152 params.slug?.join("/") || "/"
152153 )
153154 );
155+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
154156
155157 const previousPost =
156158 getPreviousPost(
@@ -168,7 +170,7 @@ export async function getStaticProps({ params }) {
168170 "weight"
169171 ) || null;
170172
171− return { props: { posts, data, content, params, previousPost, nextPost } };
173+ return { props: { posts, data, markdown, params, previousPost, nextPost } };
172174}
173175
174176export async function getStaticPaths() {
pages/updates/[slug].js+5−4
@@ -11,14 +11,14 @@ import Head from "next/head";
1111import Meta from "../../components/Meta";
1212import ErrorPage from "../404";
1313import Container from "../../components/Container";
14−import Markdown from "../../components/Markdown";
14+import Markdown, { MarkdownParse } from "../../components/Markdown";
1515import Header from "../../components/Header";
1616import Footer from "../../components/Footer";
1717import SingleColumn from "../../components/SingleColumn";
1818import Section from "../../components/Section";
1919import Contact from "../../components/Contact";
2020
21−export default function Post({ post, search }) {
21+export default function Post({ post, markdown, search }) {
2222 const router = useRouter();
2323 if (!router.isFallback && !post?.slug) {
2424 return <ErrorPage />;
@@ -51,7 +51,7 @@ export default function Post({ post, search }) {
5151 </div>
5252 </Section>
5353 <Section narrow className="markdown">
54− <Markdown post={post} />
54+ <Markdown content={JSON.parse(markdown)} />
5555 </Section>
5656 <Section narrow>
5757 <Contact />
@@ -105,9 +105,10 @@ export async function getStaticProps({ params }) {
105105 ["title", "slug", "date", "description", "content", "author", "ship"],
106106 "updates"
107107 );
108+ const markdown = JSON.stringify(MarkdownParse({ post }));
108109
109110 return {
110− props: { post, nextPost, previousPost },
111+ props: { post, markdown, nextPost, previousPost },
111112 };
112113}
113114
pages/using/[[...slug]].js+6−4
@@ -6,7 +6,7 @@ import { useState } from "react";
66import classnames from "classnames";
77import { join } from "path";
88import { getPage } from "../../lib/lib";
9−import Markdown from "../../components/Markdown";
9+import Markdown, { MarkdownParse } from "../../components/Markdown";
1010import ContentArea from "../../components/ContentArea";
1111import Sidebar from "../../components/Sidebar";
1212import UsingTree from "../../cache/using.json";
@@ -96,7 +96,7 @@ const pageTree = (thisLink, tree, level = 0) => {
9696 );
9797};
9898
99−export default function UsingLayout({ posts, data, params, search, content }) {
99+export default function UsingLayout({ posts, data, params, search, markdown }) {
100100 return (
101101 <>
102102 <Head>
@@ -115,7 +115,7 @@ export default function UsingLayout({ posts, data, params, search, content }) {
115115 params={params}
116116 >
117117 <div className="markdown">
118− <Markdown post={{ content: content }} />
118+ <Markdown content={JSON.parse(markdown)} />
119119 </div>
120120 </ContentArea>
121121 </div>
@@ -130,7 +130,9 @@ export async function getStaticProps({ params }) {
130130 join(process.cwd(), "content/using", params.slug?.join("/") || "/")
131131 );
132132
133− return { props: { posts, data, content, params } };
133+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
134+
135+ return { props: { posts, data, markdown, params } };
134136}
135137
136138export async function getStaticPaths() {
pages/voting-instructions.js+5−3
@@ -1,8 +1,9 @@
11import { getPostBySlug } from "../lib/lib";
22import BasicPage from "../components/BasicPage";
3+import { MarkdownParse } from "../components/Markdown";
34
4−export default function Post({ post, search }) {
5− return <BasicPage post={post} search={search} />;
5+export default function Post({ post, markdown, search }) {
6+ return <BasicPage post={post} markdown={markdown} search={search} />;
67}
78
89export async function getStaticProps() {
@@ -11,8 +12,9 @@ export async function getStaticProps() {
1112 ["title", "slug", "content"],
1213 "/"
1314 );
15+ const markdown = JSON.stringify(MarkdownParse({ post }));
1416
1517 return {
16− props: { post },
18+ props: { post, markdown },
1719 };
1820}