on master help sign in
components, pages: split markdown parsing into server-side
35af151Matilde Park
components/BasicPage.js+2−3
@@ -7,10 +7,9 @@ import Header from "./Header";
7import Footer from "./Footer";
7import Footer from "./Footer";
8import SingleColumn from "./SingleColumn";
8import SingleColumn from "./SingleColumn";
9import Section from "./Section";
9import Section from "./Section";
10−import { decode } from "html-entities";
11import Markdown from "./Markdown";
10import Markdown from "./Markdown";
12
11
13−export default function BasicPage({ post, search }) {
12+export default function BasicPage({ post, markdown, search }) {
14 const router = useRouter();
13 const router = useRouter();
15 if (!router.isFallback && !post?.slug) {
14 if (!router.isFallback && !post?.slug) {
16 return <ErrorPage />;
15 return <ErrorPage />;
@@ -27,7 +26,7 @@ export default function BasicPage({ post, search }) {
27 <h1>{post.title}</h1>
26 <h1>{post.title}</h1>
28 </Section>
27 </Section>
29 <Section narrow className="markdown">
28 <Section narrow className="markdown">
30− <Markdown post={post} />
29+ <Markdown content={JSON.parse(markdown)} />
31 </Section>
30 </Section>
32 </SingleColumn>
31 </SingleColumn>
33 <Footer />
32 <Footer />
components/GrantProgramOverview.js+2−1
@@ -14,6 +14,7 @@ import Markdown from "./Markdown";
14
14
15export default function GrantProgramOverview({
15export default function GrantProgramOverview({
16 post,
16 post,
17+ markdown,
17 search,
18 search,
18 program,
19 program,
19 actionLink,
20 actionLink,
@@ -45,7 +46,7 @@ export default function GrantProgramOverview({
45 </Link>
46 </Link>
46 </Section>
47 </Section>
47 <Section narrow short className="markdown">
48 <Section narrow short className="markdown">
48− <Markdown post={post} />
49+ <Markdown content={JSON.parse(markdown)} />
49 </Section>
50 </Section>
50 </SingleColumn>
51 </SingleColumn>
51 <Footer />
52 <Footer />
components/PageWithIndex.js+2−2
@@ -10,7 +10,7 @@ import Section from "./Section";
10import Markdown from "../components/Markdown";
10import Markdown from "../components/Markdown";
11import { TableOfContents } from "./TableOfContents";
11import { TableOfContents } from "./TableOfContents";
12
12
13−export default function PageWithIndex({ post, search }) {
13+export default function PageWithIndex({ post, markdown, search }) {
14 const router = useRouter();
14 const router = useRouter();
15 if (!router.isFallback && !post?.slug) {
15 if (!router.isFallback && !post?.slug) {
16 return <ErrorPage />;
16 return <ErrorPage />;
@@ -29,7 +29,7 @@ export default function PageWithIndex({ post, search }) {
29 <Section narrow>
29 <Section narrow>
30 <div className="flex sidebar">
30 <div className="flex sidebar">
31 <div className="markdown max-w-prose">
31 <div className="markdown max-w-prose">
32− <Markdown post={post} />
32+ <Markdown content={JSON.parse(markdown)} />
33 </div>
33 </div>
34 <TableOfContents />
34 <TableOfContents />
35 </div>
35 </div>
components/gateway/Description.js+3−2
@@ -1,4 +1,3 @@
1−import { decode } from "html-entities";
2import Markdown from "../Markdown";
1import Markdown from "../Markdown";
3
2
4const Description = ({ description, fallback, markdown }) => {
3const Description = ({ description, fallback, markdown }) => {
@@ -7,7 +6,9 @@ const Description = ({ description, fallback, markdown }) => {
7 <div className="flex flex-col space-y-4">
6 <div className="flex flex-col space-y-4">
8 <p className="font-bold text-wall-400">Description</p>
7 <p className="font-bold text-wall-400">Description</p>
9 {markdown ? (
8 {markdown ? (
9+ <div className="markdown">
10− <Markdown post={{ content: markdown }} />
10+ <Markdown content={JSON.parse(markdown)} />
11+ </div>
11 ) : (
12 ) : (
12 <p>{description}</p>
13 <p>{description}</p>
13 )}
14 )}
pages/applications/[[...application]].js+5−2
@@ -7,6 +7,7 @@ import Container from "../../components/Container";
7import SingleColumn from "../../components/SingleColumn";
7import SingleColumn from "../../components/SingleColumn";
8import Section from "../../components/Section";
8import Section from "../../components/Section";
9import ob from "urbit-ob";
9import ob from "urbit-ob";
10+import { MarkdownParse } from "../../components/Markdown";
10import GatewayHeader from "../../components/gateway/GatewayHeader";
11import GatewayHeader from "../../components/gateway/GatewayHeader";
11import Gateway404 from "../../components/gateway/Gateway404";
12import Gateway404 from "../../components/gateway/Gateway404";
12import MetadataBlock from "../../components/gateway/MetadataBlock";
13import MetadataBlock from "../../components/gateway/MetadataBlock";
@@ -94,7 +95,7 @@ const ApplicationPage = ({ data, content, params }) => {
94 <Description
95 <Description
95 description={data.description}
96 description={data.description}
96 fallback="An application on Urbit."
97 fallback="An application on Urbit."
97− markdown={content}
98+ markdown={markdown}
98 />
99 />
99 <hr className="text-wall-200" />
100 <hr className="text-wall-200" />
100 <div className="flex flex-col space-y-6">
101 <div className="flex flex-col space-y-6">
@@ -145,6 +146,8 @@ export const getServerSideProps = async ({ params, res }) => {
145 )
146 )
146 ) || { data: {}, content: "" };
147 ) || { data: {}, content: "" };
147
148
149+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
150+
148 if (!data.title) {
151 if (!data.title) {
149 data = {
152 data = {
150 title: params.application?.join("/"),
153 title: params.application?.join("/"),
@@ -155,7 +158,7 @@ export const getServerSideProps = async ({ params, res }) => {
155 return {
158 return {
156 props: {
159 props: {
157 data,
160 data,
158− content,
161+ markdown,
159 params,
162 params,
160 },
163 },
161 };
164 };
pages/audits.js+5−2
@@ -1,14 +1,17 @@
1import { getPostBySlug } from "../lib/lib";
1import { getPostBySlug } from "../lib/lib";
2import BasicPage from "../components/BasicPage";
2import BasicPage from "../components/BasicPage";
3+import { MarkdownParse } from "../components/Markdown";
3
4
4export default function Post({ post, search }) {
5export default function Post({ post, search }) {
5− return <BasicPage post={post} search={search} />;
6+ return <BasicPage post={post} markdown={markdown} search={search} />;
6}
7}
7
8
8export async function getStaticProps() {
9export async function getStaticProps() {
9 const post = getPostBySlug("/audits", ["title", "slug", "content"], "/");
10 const post = getPostBySlug("/audits", ["title", "slug", "content"], "/");
10
11
12+ const markdown = JSON.stringify(MarkdownParse({ post }));
13+
11 return {
14 return {
12− props: { post },
15+ props: { post, markdown },
13 };
16 };
14}
17}
pages/bitcoin-wallet.js+6−3
@@ -1,8 +1,9 @@
1import { getPostBySlug } from "../lib/lib";
1import { getPostBySlug } from "../lib/lib";
2import BasicPage from "../components/BasicPage";
2import BasicPage from "../components/BasicPage";
3+import { MarkdownParse } from "../components/Markdown";
3
4
4−export default function Post({ post, search }) {
5+export default function Post({ post, markdown, search }) {
5− return <BasicPage post={post} search={search} />;
6+ return <BasicPage post={post} markdown={markdown} search={search} />;
6}
7}
7
8
8export async function getStaticProps() {
9export async function getStaticProps() {
@@ -12,7 +13,9 @@ export async function getStaticProps() {
12 "/"
13 "/"
13 );
14 );
14
15
16+ const markdown = JSON.stringify(MarkdownParse({ post }));
17+
15 return {
18 return {
16− props: { post },
19+ props: { post, markdown },
17 };
20 };
18}
21}
pages/blog/[slug].js+11−4
@@ -19,9 +19,15 @@ import Section from "../../components/Section";
19import Contact from "../../components/Contact";
19import Contact from "../../components/Contact";
20import PostPreview from "../../components/PostPreview";
20import PostPreview from "../../components/PostPreview";
21import TwoUp from "../../components/TwoUp";
21import TwoUp from "../../components/TwoUp";
22−import Markdown from "../../components/Markdown";
22+import Markdown, { MarkdownParse } from "../../components/Markdown";
23
23
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+}) {
25 const router = useRouter();
31 const router = useRouter();
26 if (!router.isFallback && !post?.slug) {
32 if (!router.isFallback && !post?.slug) {
27 return <ErrorPage />;
33 return <ErrorPage />;
@@ -53,7 +59,7 @@ export default function Post({ post, nextPost, previousPost, search }) {
53 <div className="text-wall-500 type-sub">{formatDate(date)}</div>
59 <div className="text-wall-500 type-sub">{formatDate(date)}</div>
54 </Section>
60 </Section>
55 <Section short narrow className="markdown">
61 <Section short narrow className="markdown">
56− <Markdown post={post} />
62+ <Markdown content={JSON.parse(markdown)} />
57 </Section>
63 </Section>
58 <Section narrow>
64 <Section narrow>
59 <Contact />
65 <Contact />
@@ -96,8 +102,9 @@ export async function getStaticProps({ params }) {
96 "blog"
102 "blog"
97 );
103 );
98
104
105+ const markdown = JSON.stringify(MarkdownParse({ post }));
99 return {
106 return {
100− props: { post, nextPost, previousPost },
107+ props: { post, markdown, nextPost, previousPost },
101 };
108 };
102}
109}
103
110
pages/coinmarketcap.js+6−3
@@ -1,8 +1,9 @@
1import { getPostBySlug } from "../lib/lib";
1import { getPostBySlug } from "../lib/lib";
2import PageWithIndex from "../components/PageWithIndex";
2import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
3
4
4−export default function Post({ post, search }) {
5+export default function Post({ post, markdown, search }) {
5− return <PageWithIndex post={post} search={search} />;
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
6}
7}
7
8
8export async function getStaticProps() {
9export async function getStaticProps() {
@@ -12,7 +13,9 @@ export async function getStaticProps() {
12 "/"
13 "/"
13 );
14 );
14
15
16+ const markdown = JSON.stringify(MarkdownParse({ post }));
17+
15 return {
18 return {
16− props: { post },
19+ props: { post, markdown },
17 };
20 };
18}
21}
pages/community/[[...slug]].js+6−4
@@ -5,7 +5,7 @@ import classnames from "classnames";
5import { join } from "path";
5import { join } from "path";
6import { getPage } from "../../lib/lib";
6import { getPage } from "../../lib/lib";
7import Meta from "../../components/Meta";
7import Meta from "../../components/Meta";
8−import Markdown from "../../components/Markdown";
8+import Markdown, { MarkdownParse } from "../../components/Markdown";
9import ContentArea from "../../components/ContentArea";
9import ContentArea from "../../components/ContentArea";
10import Sidebar from "../../components/Sidebar";
10import Sidebar from "../../components/Sidebar";
11import communityTree from "../../cache/community.json";
11import communityTree from "../../cache/community.json";
@@ -58,7 +58,7 @@ const pageTree = (thisLink, tree, level = 0) => {
58 );
58 );
59};
59};
60
60
61−export default function UsingLayout({ posts, data, params, search, content }) {
61+export default function UsingLayout({ posts, data, markdown, params, search }) {
62 return (
62 return (
63 <>
63 <>
64 <Head>
64 <Head>
@@ -77,7 +77,7 @@ export default function UsingLayout({ posts, data, params, search, content }) {
77 params={params}
77 params={params}
78 >
78 >
79 <div className="markdown">
79 <div className="markdown">
80− <Markdown post={{ content: content }} />
80+ <Markdown content={JSON.parse(markdown)} />
81 </div>
81 </div>
82 </ContentArea>
82 </ContentArea>
83 </div>
83 </div>
@@ -92,7 +92,9 @@ export async function getStaticProps({ params }) {
92 join(process.cwd(), "content/community", params.slug?.join("/") || "/")
92 join(process.cwd(), "content/community", params.slug?.join("/") || "/")
93 );
93 );
94
94
95+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
96+
95− return { props: { posts, data, content, params } };
97+ return { props: { posts, data, markdown, params } };
96}
98}
97
99
98export async function getStaticPaths() {
100export async function getStaticPaths() {
pages/docs/[[...slug]].js+5−4
@@ -7,7 +7,7 @@ import { join } from "path";
7import { getPreviousPost, getNextPost, getPage } from "../../lib/lib";
7import { getPreviousPost, getNextPost, getPage } from "../../lib/lib";
8import Meta from "../../components/Meta";
8import Meta from "../../components/Meta";
9import Pagination from "../../components/Pagination";
9import Pagination from "../../components/Pagination";
10−import Markdown from "../../components/Markdown";
10+import Markdown, { MarkdownParse } from "../../components/Markdown";
11import ContentArea from "../../components/ContentArea";
11import ContentArea from "../../components/ContentArea";
12import Sidebar from "../../components/Sidebar";
12import Sidebar from "../../components/Sidebar";
13import docsPageTree from "../../cache/docs.json";
13import docsPageTree from "../../cache/docs.json";
@@ -103,7 +103,7 @@ export default function DocsLayout({
103 data,
103 data,
104 params,
104 params,
105 search,
105 search,
106− content,
106+ markdown,
107 previousPost,
107 previousPost,
108 nextPost,
108 nextPost,
109}) {
109}) {
@@ -144,7 +144,7 @@ export default function DocsLayout({
144 params={params}
144 params={params}
145 >
145 >
146 <div className="markdown technical">
146 <div className="markdown technical">
147− <Markdown post={{ content: content }} />
147+ <Markdown content={JSON.parse(markdown)} />
148 </div>
148 </div>
149 <div className="flex justify-between mt-16">
149 <div className="flex justify-between mt-16">
150 {previousPost === null ? (
150 {previousPost === null ? (
@@ -208,7 +208,8 @@ export async function getStaticProps({ params }) {
208 "weight"
208 "weight"
209 ) || null;
209 ) || null;
210
210
211+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
211− return { props: { posts, data, content, previousPost, nextPost, params } };
212+ return { props: { posts, data, markdown, previousPost, nextPost, params } };
212}
213}
213
214
214export async function getStaticPaths() {
215export async function getStaticPaths() {
pages/events/[slug].js+12−4
@@ -10,7 +10,7 @@ import {
10import Head from "next/head";
10import Head from "next/head";
11import Meta from "../../components/Meta";
11import Meta from "../../components/Meta";
12import Container from "../../components/Container";
12import Container from "../../components/Container";
13−import Markdown from "../../components/Markdown";
13+import Markdown, { MarkdownParse } from "../../components/Markdown";
14import Header from "../../components/Header";
14import Header from "../../components/Header";
15import Footer from "../../components/Footer";
15import Footer from "../../components/Footer";
16import SingleColumn from "../../components/SingleColumn";
16import SingleColumn from "../../components/SingleColumn";
@@ -27,7 +27,13 @@ import {
27} from "../../components/Snippets";
27} from "../../components/Snippets";
28import { eventKeys } from "../../lib/constants";
28import { eventKeys } from "../../lib/constants";
29
29
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+}) {
31 const starts = generateDisplayDate(event.starts, event.timezone);
37 const starts = generateDisplayDate(event.starts, event.timezone);
32 const ends = generateDisplayDate(event.ends, event.timezone);
38 const ends = generateDisplayDate(event.ends, event.timezone);
33
39
@@ -110,7 +116,7 @@ export default function Event({ event, nextEvent, previousEvent, search }) {
110 ) : null}
116 ) : null}
111
117
112 <Section short narrow className="markdown">
118 <Section short narrow className="markdown">
113− <Markdown post={event} />
119+ <Markdown content={JSON.parse(markdown)} />
114 </Section>
120 </Section>
115 <Section narrow>
121 <Section narrow>
116 <Contact />
122 <Contact />
@@ -147,8 +153,10 @@ export async function getStaticProps({ params }) {
147
153
148 const event = getPostBySlug(params.slug, eventKeys, "events");
154 const event = getPostBySlug(params.slug, eventKeys, "events");
149
155
156+ const markdown = JSON.stringify(MarkdownParse({ post: event }));
157+
150 return {
158 return {
151− props: { event, nextEvent, previousEvent },
159+ props: { event, markdown, nextEvent, previousEvent },
152 };
160 };
153}
161}
154
162
pages/faq.js+5−3
@@ -1,14 +1,16 @@
1import { getPostBySlug } from "../lib/lib";
1import { getPostBySlug } from "../lib/lib";
2import PageWithIndex from "../components/PageWithIndex";
2import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
3
4
4−export default function Post({ post, search }) {
5+export default function Post({ post, markdown, search }) {
5− return <PageWithIndex post={post} search={search} />;
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
6}
7}
7
8
8export async function getStaticProps() {
9export async function getStaticProps() {
9 const post = getPostBySlug("/faq", ["title", "slug", "content"], "/");
10 const post = getPostBySlug("/faq", ["title", "slug", "content"], "/");
10
11
12+ const markdown = JSON.stringify(MarkdownParse({ post }));
11 return {
13 return {
12− props: { post },
14+ props: { post, markdown },
13 };
15 };
14}
16}
pages/getting-started/[[...slug]].js+6−4
@@ -5,12 +5,12 @@ import { useRouter } from "next/router";
5import classnames from "classnames";
5import classnames from "classnames";
6import { join } from "path";
6import { join } from "path";
7import { getPage } from "../../lib/lib";
7import { getPage } from "../../lib/lib";
8−import Markdown from "../../components/Markdown";
8+import Markdown, { MarkdownParse } from "../../components/Markdown";
9import ContentArea from "../../components/ContentArea";
9import ContentArea from "../../components/ContentArea";
10import Sidebar from "../../components/Sidebar";
10import Sidebar from "../../components/Sidebar";
11import GettingStartedTree from "../../cache/getting-started.json";
11import GettingStartedTree from "../../cache/getting-started.json";
12
12
13−export default function UsingLayout({ posts, data, params, search, content }) {
13+export default function UsingLayout({ posts, data, params, search, markdown }) {
14 const router = useRouter();
14 const router = useRouter();
15
15
16 const select = (href) => {
16 const select = (href) => {
@@ -86,7 +86,7 @@ export default function UsingLayout({ posts, data, params, search, content }) {
86 disableToC
86 disableToC
87 >
87 >
88 <div className="markdown">
88 <div className="markdown">
89− <Markdown post={{ content: content }} />
89+ <Markdown content={JSON.parse(markdown)} />
90 </div>
90 </div>
91 {!params?.slug && <LaunchCards />}
91 {!params?.slug && <LaunchCards />}
92 </ContentArea>
92 </ContentArea>
@@ -290,7 +290,9 @@ export async function getStaticProps({ params }) {
290 )
290 )
291 );
291 );
292
292
293+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
294+
293− return { props: { posts, data, content, params } };
295+ return { props: { posts, data, markdown, params } };
294}
296}
295
297
296export async function getStaticPaths() {
298export async function getStaticPaths() {
pages/grants/[slug].js+5−4
@@ -6,7 +6,7 @@ import Meta from "../../components/Meta";
6import classnames from "classnames";
6import classnames from "classnames";
7import ErrorPage from "../404";
7import ErrorPage from "../404";
8import Container from "../../components/Container";
8import Container from "../../components/Container";
9−import Markdown from "../../components/Markdown";
9+import Markdown, { MarkdownParse } from "../../components/Markdown";
10import Header from "../../components/Header";
10import Header from "../../components/Header";
11import Footer from "../../components/Footer";
11import Footer from "../../components/Footer";
12import SingleColumn from "../../components/SingleColumn";
12import SingleColumn from "../../components/SingleColumn";
@@ -14,7 +14,7 @@ import ob from "urbit-ob";
14import Section from "../../components/Section";
14import Section from "../../components/Section";
15import { DateTime } from "luxon";
15import { DateTime } from "luxon";
16
16
17−export default function Grant({ post, search }) {
17+export default function Grant({ post, markdown, search }) {
18 const router = useRouter();
18 const router = useRouter();
19 if (!router.isFallback && !post?.slug) {
19 if (!router.isFallback && !post?.slug) {
20 return <ErrorPage />;
20 return <ErrorPage />;
@@ -102,7 +102,7 @@ export default function Grant({ post, search }) {
102 </div>
102 </div>
103 </Section>
103 </Section>
104 <Section narrow className="markdown">
104 <Section narrow className="markdown">
105− <Markdown post={post} />
105+ <Markdown content={JSON.parse(markdown)} />
106 </Section>
106 </Section>
107 {canApply && (
107 {canApply && (
108 <a
108 <a
@@ -127,8 +127,9 @@ export async function getStaticProps({ params }) {
127 "grants"
127 "grants"
128 );
128 );
129
129
130+ const markdown = JSON.stringify(MarkdownParse({ post }));
130 return {
131 return {
131− props: { post },
132+ props: { post, markdown },
132 };
133 };
133}
134}
134
135
pages/groups/[[...group]].js+6−4
@@ -7,14 +7,14 @@ import Container from "../../components/Container";
7import SingleColumn from "../../components/SingleColumn";
7import SingleColumn from "../../components/SingleColumn";
8import Section from "../../components/Section";
8import Section from "../../components/Section";
9import ob from "urbit-ob";
9import ob from "urbit-ob";
10−import Markdown from "../../components/Markdown";
10+import { MarkdownParse } from "../../components/Markdown";
11import GatewayHeader from "../../components/gateway/GatewayHeader";
11import GatewayHeader from "../../components/gateway/GatewayHeader";
12import Gateway404 from "../../components/gateway/Gateway404";
12import Gateway404 from "../../components/gateway/Gateway404";
13import MetadataBlock from "../../components/gateway/MetadataBlock";
13import MetadataBlock from "../../components/gateway/MetadataBlock";
14import MetadataLink from "../../components/gateway/MetadataLink";
14import MetadataLink from "../../components/gateway/MetadataLink";
15import Description from "../../components/gateway/Description";
15import Description from "../../components/gateway/Description";
16
16
17−const GroupPage = ({ data, content, params }) => {
17+const GroupPage = ({ data, markdown, params }) => {
18 const { group } = params;
18 const { group } = params;
19 if (!ob.isValidPatp(group?.[0] || "")) {
19 if (!ob.isValidPatp(group?.[0] || "")) {
20 return <Gateway404 type="group" />;
20 return <Gateway404 type="group" />;
@@ -89,7 +89,7 @@ const GroupPage = ({ data, content, params }) => {
89 <Description
89 <Description
90 description={data.description}
90 description={data.description}
91 fallback="A group on Urbit."
91 fallback="A group on Urbit."
92− markdown={content}
92+ markdown={markdown}
93 />
93 />
94 <hr className="text-wall-200" />
94 <hr className="text-wall-200" />
95 <div className="flex flex-col space-y-6">
95 <div className="flex flex-col space-y-6">
@@ -133,6 +133,8 @@ export const getServerSideProps = async ({ params, res }) => {
133 join(process.cwd(), "content/groups", params.group?.join("/") || "/")
133 join(process.cwd(), "content/groups", params.group?.join("/") || "/")
134 ) || { data: {}, content: "" };
134 ) || { data: {}, content: "" };
135
135
136+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
137+
136 if (!data.title) {
138 if (!data.title) {
137 data = { title: params.group?.join("/"), description: "A group on Urbit." };
139 data = { title: params.group?.join("/"), description: "A group on Urbit." };
138 }
140 }
@@ -140,7 +142,7 @@ export const getServerSideProps = async ({ params, res }) => {
140 return {
142 return {
141 props: {
143 props: {
142 data,
144 data,
143− content,
145+ markdown,
144 params,
146 params,
145 },
147 },
146 };
148 };
pages/ids/[id].js+6−3
@@ -13,8 +13,9 @@ import MetadataBlock from "../../components/gateway/MetadataBlock";
13import MetadataLink from "../../components/gateway/MetadataLink";
13import MetadataLink from "../../components/gateway/MetadataLink";
14import Description from "../../components/gateway/Description";
14import Description from "../../components/gateway/Description";
15import axios from "axios";
15import axios from "axios";
16+import { MarkdownParse } from "../../components/Markdown";
16
17
17−const IdPage = ({ data, content, applications, groups, network, params }) => {
18+const IdPage = ({ data, markdown, applications, groups, network, params }) => {
18 let { id } = params;
19 let { id } = params;
19 id = `~${deSig(id)}`;
20 id = `~${deSig(id)}`;
20 if (!ob.isValidPatp(id) || id.length > 14) {
21 if (!ob.isValidPatp(id) || id.length > 14) {
@@ -109,7 +110,7 @@ const IdPage = ({ data, content, applications, groups, network, params }) => {
109 <Description
110 <Description
110 description={data.description}
111 description={data.description}
111 fallback="An Urbit ID."
112 fallback="An Urbit ID."
112− markdown={content}
113+ markdown={markdown}
113 />
114 />
114 <a
115 <a
115 className="flex items-center"
116 className="flex items-center"
@@ -206,6 +207,8 @@ export const getServerSideProps = async ({ params, res }) => {
206 join(process.cwd(), "content/ids/", id.slice(1))
207 join(process.cwd(), "content/ids/", id.slice(1))
207 ) || { data: {}, content: "" };
208 ) || { data: {}, content: "" };
208
209
210+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
211+
209 const applications = getAllPosts(
212 const applications = getAllPosts(
210 ["title", "slug", "image", "bgColor"],
213 ["title", "slug", "image", "bgColor"],
211 `applications/${params.id}`
214 `applications/${params.id}`
@@ -229,7 +232,7 @@ export const getServerSideProps = async ({ params, res }) => {
229 data,
232 data,
230 applications,
233 applications,
231 groups,
234 groups,
232− content,
235+ markdown,
233 network,
236 network,
234 params,
237 params,
235 },
238 },
pages/media/[slug].js+6−4
@@ -10,14 +10,14 @@ import Link from "next/link";
10import Meta from "../../components/Meta";
10import Meta from "../../components/Meta";
11import ErrorPage from "../404";
11import ErrorPage from "../404";
12import Container from "../../components/Container";
12import Container from "../../components/Container";
13−import Markdown from "../../components/Markdown";
13+import Markdown, { MarkdownParse } from "../../components/Markdown";
14import Header from "../../components/Header";
14import Header from "../../components/Header";
15import Footer from "../../components/Footer";
15import Footer from "../../components/Footer";
16import SingleColumn from "../../components/SingleColumn";
16import SingleColumn from "../../components/SingleColumn";
17import Contact from "../../components/Contact";
17import Contact from "../../components/Contact";
18import Section from "../../components/Section";
18import Section from "../../components/Section";
19
19
20−export default function MediaPage({ post, search }) {
20+export default function MediaPage({ post, markdown, search }) {
21 const router = useRouter();
21 const router = useRouter();
22 if (!router.isFallback && !post?.slug) {
22 if (!router.isFallback && !post?.slug) {
23 return <ErrorPage />;
23 return <ErrorPage />;
@@ -71,7 +71,7 @@ export default function MediaPage({ post, search }) {
71 ) : null}
71 ) : null}
72 </Section>
72 </Section>
73 <Section narrow className="markdown">
73 <Section narrow className="markdown">
74− <Markdown post={post} />
74+ <Markdown content={JSON.parse(markdown)} />
75 </Section>
75 </Section>
76 <Section narrow>
76 <Section narrow>
77 <Contact />
77 <Contact />
@@ -90,8 +90,10 @@ export async function getStaticProps({ params }) {
90 "media"
90 "media"
91 );
91 );
92
92
93+ const markdown = JSON.stringify(MarkdownParse({ post }));
94+
93 return {
95 return {
94− props: { post },
96+ props: { post, markdown },
95 };
97 };
96}
98}
97
99
pages/privacy.js+6−3
@@ -1,14 +1,17 @@
1import { getPostBySlug } from "../lib/lib";
1import { getPostBySlug } from "../lib/lib";
2import PageWithIndex from "../components/PageWithIndex";
2import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
3
4
4−export default function Post({ post, search }) {
5+export default function Post({ post, markdown, search }) {
5− return <PageWithIndex post={post} search={search} />;
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
6}
7}
7
8
8export async function getStaticProps() {
9export async function getStaticProps() {
9 const post = getPostBySlug("/privacy", ["title", "slug", "content"], "/");
10 const post = getPostBySlug("/privacy", ["title", "slug", "content"], "/");
10
11
12+ const markdown = JSON.stringify(MarkdownParse({ post }));
13+
11 return {
14 return {
12− props: { post },
15+ props: { post, markdown },
13 };
16 };
14}
17}
pages/terms-of-service.js+5−3
@@ -1,8 +1,9 @@
1import { getPostBySlug } from "../lib/lib";
1import { getPostBySlug } from "../lib/lib";
2import PageWithIndex from "../components/PageWithIndex";
2import PageWithIndex from "../components/PageWithIndex";
3+import { MarkdownParse } from "../components/Markdown";
3
4
4−export default function Post({ post, search }) {
5+export default function Post({ post, markdown, search }) {
5− return <PageWithIndex post={post} search={search} />;
6+ return <PageWithIndex post={post} markdown={markdown} search={search} />;
6}
7}
7
8
8export async function getStaticProps() {
9export async function getStaticProps() {
@@ -12,7 +13,8 @@ export async function getStaticProps() {
12 "/"
13 "/"
13 );
14 );
14
15
16+ const markdown = JSON.stringify(MarkdownParse({ post }));
15 return {
17 return {
16− props: { post },
18+ props: { post, markdown },
17 };
19 };
18}
20}
pages/understanding-urbit/[[...slug]].js+6−4
@@ -5,7 +5,7 @@ import { useRouter } from "next/router";
5import classnames from "classnames";
5import classnames from "classnames";
6import { join } from "path";
6import { join } from "path";
7import { getPage, getPreviousPost, getNextPost } from "../../lib/lib";
7import { getPage, getPreviousPost, getNextPost } from "../../lib/lib";
8−import Markdown from "../../components/Markdown";
8+import Markdown, { MarkdownParse } from "../../components/Markdown";
9import ContentArea from "../../components/ContentArea";
9import ContentArea from "../../components/ContentArea";
10import Sidebar from "../../components/Sidebar";
10import Sidebar from "../../components/Sidebar";
11import Pagination from "../../components/Pagination";
11import Pagination from "../../components/Pagination";
@@ -64,7 +64,7 @@ export default function UnderstandingLayout({
64 data,
64 data,
65 params,
65 params,
66 search,
66 search,
67− content,
67+ markdown,
68 previousPost,
68 previousPost,
69 nextPost,
69 nextPost,
70}) {
70}) {
@@ -101,9 +101,10 @@ export default function UnderstandingLayout({
101 search={search}
101 search={search}
102 section={"Understanding Urbit"}
102 section={"Understanding Urbit"}
103 params={params}
103 params={params}
104+ disableToC
104 >
105 >
105 <div className="markdown">
106 <div className="markdown">
106− <Markdown post={{ content: content }} />
107+ <Markdown content={JSON.parse(markdown)} />
107 </div>
108 </div>
108 <div className="flex justify-between mt-16">
109 <div className="flex justify-between mt-16">
109 {previousPost === null ? (
110 {previousPost === null ? (
@@ -151,6 +152,7 @@ export async function getStaticProps({ params }) {
151 params.slug?.join("/") || "/"
152 params.slug?.join("/") || "/"
152 )
153 )
153 );
154 );
155+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
154
156
155 const previousPost =
157 const previousPost =
156 getPreviousPost(
158 getPreviousPost(
@@ -168,7 +170,7 @@ export async function getStaticProps({ params }) {
168 "weight"
170 "weight"
169 ) || null;
171 ) || null;
170
172
171− return { props: { posts, data, content, params, previousPost, nextPost } };
173+ return { props: { posts, data, markdown, params, previousPost, nextPost } };
172}
174}
173
175
174export async function getStaticPaths() {
176export async function getStaticPaths() {
pages/updates/[slug].js+5−4
@@ -11,14 +11,14 @@ import Head from "next/head";
11import Meta from "../../components/Meta";
11import Meta from "../../components/Meta";
12import ErrorPage from "../404";
12import ErrorPage from "../404";
13import Container from "../../components/Container";
13import Container from "../../components/Container";
14−import Markdown from "../../components/Markdown";
14+import Markdown, { MarkdownParse } from "../../components/Markdown";
15import Header from "../../components/Header";
15import Header from "../../components/Header";
16import Footer from "../../components/Footer";
16import Footer from "../../components/Footer";
17import SingleColumn from "../../components/SingleColumn";
17import SingleColumn from "../../components/SingleColumn";
18import Section from "../../components/Section";
18import Section from "../../components/Section";
19import Contact from "../../components/Contact";
19import Contact from "../../components/Contact";
20
20
21−export default function Post({ post, search }) {
21+export default function Post({ post, markdown, search }) {
22 const router = useRouter();
22 const router = useRouter();
23 if (!router.isFallback && !post?.slug) {
23 if (!router.isFallback && !post?.slug) {
24 return <ErrorPage />;
24 return <ErrorPage />;
@@ -51,7 +51,7 @@ export default function Post({ post, search }) {
51 </div>
51 </div>
52 </Section>
52 </Section>
53 <Section narrow className="markdown">
53 <Section narrow className="markdown">
54− <Markdown post={post} />
54+ <Markdown content={JSON.parse(markdown)} />
55 </Section>
55 </Section>
56 <Section narrow>
56 <Section narrow>
57 <Contact />
57 <Contact />
@@ -105,9 +105,10 @@ export async function getStaticProps({ params }) {
105 ["title", "slug", "date", "description", "content", "author", "ship"],
105 ["title", "slug", "date", "description", "content", "author", "ship"],
106 "updates"
106 "updates"
107 );
107 );
108+ const markdown = JSON.stringify(MarkdownParse({ post }));
108
109
109 return {
110 return {
110− props: { post, nextPost, previousPost },
111+ props: { post, markdown, nextPost, previousPost },
111 };
112 };
112}
113}
113
114
pages/using/[[...slug]].js+6−4
@@ -6,7 +6,7 @@ import { useState } from "react";
6import classnames from "classnames";
6import classnames from "classnames";
7import { join } from "path";
7import { join } from "path";
8import { getPage } from "../../lib/lib";
8import { getPage } from "../../lib/lib";
9−import Markdown from "../../components/Markdown";
9+import Markdown, { MarkdownParse } from "../../components/Markdown";
10import ContentArea from "../../components/ContentArea";
10import ContentArea from "../../components/ContentArea";
11import Sidebar from "../../components/Sidebar";
11import Sidebar from "../../components/Sidebar";
12import UsingTree from "../../cache/using.json";
12import UsingTree from "../../cache/using.json";
@@ -96,7 +96,7 @@ const pageTree = (thisLink, tree, level = 0) => {
96 );
96 );
97};
97};
98
98
99−export default function UsingLayout({ posts, data, params, search, content }) {
99+export default function UsingLayout({ posts, data, params, search, markdown }) {
100 return (
100 return (
101 <>
101 <>
102 <Head>
102 <Head>
@@ -115,7 +115,7 @@ export default function UsingLayout({ posts, data, params, search, content }) {
115 params={params}
115 params={params}
116 >
116 >
117 <div className="markdown">
117 <div className="markdown">
118− <Markdown post={{ content: content }} />
118+ <Markdown content={JSON.parse(markdown)} />
119 </div>
119 </div>
120 </ContentArea>
120 </ContentArea>
121 </div>
121 </div>
@@ -130,7 +130,9 @@ export async function getStaticProps({ params }) {
130 join(process.cwd(), "content/using", params.slug?.join("/") || "/")
130 join(process.cwd(), "content/using", params.slug?.join("/") || "/")
131 );
131 );
132
132
133+ const markdown = JSON.stringify(MarkdownParse({ post: { content } }));
134+
133− return { props: { posts, data, content, params } };
135+ return { props: { posts, data, markdown, params } };
134}
136}
135
137
136export async function getStaticPaths() {
138export async function getStaticPaths() {
pages/voting-instructions.js+5−3
@@ -1,8 +1,9 @@
1import { getPostBySlug } from "../lib/lib";
1import { getPostBySlug } from "../lib/lib";
2import BasicPage from "../components/BasicPage";
2import BasicPage from "../components/BasicPage";
3+import { MarkdownParse } from "../components/Markdown";
3
4
4−export default function Post({ post, search }) {
5+export default function Post({ post, markdown, search }) {
5− return <BasicPage post={post} search={search} />;
6+ return <BasicPage post={post} markdown={markdown} search={search} />;
6}
7}
7
8
8export async function getStaticProps() {
9export async function getStaticProps() {
@@ -11,8 +12,9 @@ export async function getStaticProps() {
11 ["title", "slug", "content"],
12 ["title", "slug", "content"],
12 "/"
13 "/"
13 );
14 );
15+ const markdown = JSON.stringify(MarkdownParse({ post }));
14
16
15 return {
17 return {
16− props: { post },
18+ props: { post, markdown },
17 };
19 };
18}
20}