Skip to content

Commit 9fe79d8

Browse files
committed
rendering community pages
1 parent 0a505e7 commit 9fe79d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+42
-8921
lines changed

app/routes.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ let $$default = Belt_Array.concatMany([
2424
Routes.index("./routes/LandingPageRoute.mjs"),
2525
Routes.route("packages", "./routes/PackagesRoute.mjs"),
2626
Routes.route("try", "./routes/TryRoute.mjs"),
27-
Routes.route("community", "./routes/CommunityRoute.mjs"),
28-
Routes.route("community/overview", "./routes/CommunityRoute.mjs", {
29-
id: "overview"
30-
}),
3127
Routes.route("syntax-lookup", "./routes/SyntaxLookupRoute.mjs", {
3228
id: "syntax-lookup"
3329
}),

app/routes.res

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ let default = [
1818
index("./routes/LandingPageRoute.mjs"),
1919
route("packages", "./routes/PackagesRoute.mjs"),
2020
route("try", "./routes/TryRoute.mjs"),
21-
route("community", "./routes/CommunityRoute.mjs"),
22-
route("community/overview", "./routes/CommunityRoute.mjs", ~options={id: "overview"}),
2321
route("syntax-lookup", "./routes/SyntaxLookupRoute.mjs", ~options={id: "syntax-lookup"}),
2422
route("blog", "./routes/BlogRoute.mjs", ~options={id: "blog-index"}),
2523
route("blog/archived", "./routes/BlogRoute.mjs", ~options={id: "blog-archived"}),

app/routes/MdxRoute.res

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type loaderData = {
66
categories: array<SidebarLayout.Sidebar.Category.t>,
77
entries: array<TableOfContents.entry>,
88
blogPost?: BlogApi.post,
9+
resources?: array<CommunityContent.link>,
910
}
1011

1112
/**
@@ -42,6 +43,7 @@ let components = {
4243
"UrlBox": Markdown.UrlBox.make,
4344
"Video": Markdown.Video.make,
4445
"Warn": Markdown.Warn.make,
46+
"CommunityContent": CommunityContent.make,
4547
}
4648

4749
let convertToNavItems = (items, rootPath) =>
@@ -112,6 +114,22 @@ let reactTableOfContents = async () => {
112114
categories
113115
}
114116

117+
let communityTableOfContents = async () => {
118+
let groups =
119+
(await allMdx())
120+
->filterMdxPages("community")
121+
->groupBySection
122+
->Dict.mapValues(values => values->sortSection->convertToNavItems("/community"))
123+
124+
// these are the categories that appear in the sidebar
125+
let categories: array<SidebarLayout.Sidebar.Category.t> = getAllGroups(groups, ["Resources"])
126+
127+
categories
128+
}
129+
130+
@module("../../data/resources.json")
131+
external resources: array<CommunityContent.link> = "default"
132+
115133
let loader: Loader.t<loaderData> = async ({request}) => {
116134
let {pathname} = WebAPI.URL.make(~url=request.url)
117135

@@ -138,6 +156,8 @@ let loader: Loader.t<loaderData> = async ({request}) => {
138156
await manualTableOfContents()
139157
} else if pathname->String.includes("docs/react") {
140158
await reactTableOfContents()
159+
} else if pathname->String.includes("community") {
160+
await communityTableOfContents()
141161
} else {
142162
[]
143163
}
@@ -173,6 +193,7 @@ let loader: Loader.t<loaderData> = async ({request}) => {
173193
attributes: mdx.attributes,
174194
entries,
175195
categories,
196+
resources,
176197
}
177198

178199
res
@@ -205,11 +226,18 @@ let default = () => {
205226
<DocsLayout metaTitleCategory categories activeToc={title: "Introduction", entries}>
206227
<div className="markdown-body"> {component()} </div>
207228
</DocsLayout>
229+
} else if (pathname :> string)->String.includes("community") {
230+
let resources = loaderData.resources->Option.getOr([])
231+
<div>
232+
<SidebarLayout.Sidebar
233+
categories={categories} isOpen={true} route={pathname} toggle={() => ()}
234+
/>
235+
<div className="markdown-body"> {component()} </div>
236+
</div>
208237
} else {
209238
switch loaderData.blogPost {
210-
| Some({frontmatter, archived, path}) => <BlogArticle frontmatter isArchived=archived path>
211-
{component()}
212-
</BlogArticle>
239+
| Some({frontmatter, archived, path}) =>
240+
<BlogArticle frontmatter isArchived=archived path> {component()} </BlogArticle>
213241
| None => React.null // TODO: RR7 show an error
214242
}
215243
}}

app/routes/MdxRoute.resi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ type loaderData = {
33
categories: array<SidebarLayout.Sidebar.Category.t>,
44
entries: array<TableOfContents.entry>,
55
blogPost?: BlogApi.post,
6+
resources?: array<CommunityContent.link>,
67
}
78

89
let loader: ReactRouter.Loader.t<loaderData>

pages/community/code-of-conduct.mdx renamed to community/code-of-conduct.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: "Code of Conduct"
33
description: "Our working codex for the ReScript community"
44
canonical: "/community/code-of-conduct"
5+
section: "Resources"
56
---
67

78
# Code of Conduct

pages/community/content.mdx renamed to community/content.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: "Content"
33
description: "Community Content"
44
canonical: "/community/content"
5+
section: "Resources"
56
---
67

78
import CommunityContent from "src/CommunityContent.mjs";

pages/community/overview.mdx renamed to community/overview.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: "Overview"
33
description: "Community Resources Overview"
44
canonical: "/community/overview"
5+
section: "Resources"
56
---
67

78
# Community Overview

pages/community/roadmap.mdx renamed to community/roadmap.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: "Roadmap"
33
description: "Goals & Future Releases"
44
canonical: "/community/roadmap"
5+
section: "Resources"
56
---
67

78
# Roadmap

pages/community/translations.mdx renamed to community/translations.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: "Translations"
33
description: "Translation Sites"
44
canonical: "/community/translation"
5+
section: "Resources"
56
---
67

78
# Translations

0 commit comments

Comments
 (0)