Skip to content

Commit 1046aee

Browse files
committed
Adapt GenType & Community docs to new layout architecture
- Create sidebar files - Also adds missing frontmatters
1 parent bc38dac commit 1046aee

20 files changed

+148
-288
lines changed

data/sidebar_community.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"Resources": [
3+
"overview",
4+
"code-of-conduct"
5+
]
6+
}

data/sidebar_gentype_latest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Overview": [
3+
"introduction",
4+
"getting-started",
5+
"usage"
6+
],
7+
"Advanced": [
8+
"supported-types"
9+
]
10+
}

next.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ const config = {
2828
}
2929
}
3030
return config
31-
}
31+
},
32+
async redirects() {
33+
return [
34+
{
35+
source: '/community',
36+
destination: '/community/overview',
37+
permanent: true,
38+
},
39+
]
40+
},
3241
};
3342

3443
module.exports = withMdx(withTM(withCSS(config)));

pages/community/code-of-conduct.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: "Code of Conduct"
3+
description: "Our working codex for the ReScript community"
4+
canonical: "/community/code-of-conduct"
5+
---
6+
17
# Code of Conduct
28

39
## Our Pledge

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: "Overview"
3+
description: "Community Resources Overview"
4+
canonical: "/community/overview"
5+
---
6+
17
# Community
28

39
## Core Team

pages/docs/gentype/latest/getting-started.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: "Getting Started"
3+
description: "How to get started with genType in your ReScript projects"
4+
canonical: "/docs/gentype/latest/getting-started"
5+
---
6+
17
# Getting Started
28

39
`genType` is tightly integrated in the ReScript Compiler. It only requires minimal setup.

pages/docs/gentype/latest/introduction.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: "Introduction"
3+
description: "GenType - Interoperability between ReScript and TypeScript / Flow"
4+
canonical: "/docs/gentype/latest/introduction"
5+
---
6+
17
# GenType
28

39
`genType` is a code generation tool that lets you export ReScript values and types to use in JavaScript, and import JavaScript values and types into ReScript.

pages/docs/gentype/latest/supported-types.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: "Supported Types"
3+
description: "Supported types and value convertion in GenType"
4+
canonical: "/docs/gentype/latest/supported-types"
5+
---
6+
17
# Supported Types
28

39
<Intro>

scripts/extract-tocs.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,39 @@ const createV800ManualToc = () => {
181181

182182
const createGenTypeToc = () => {
183183
const MD_DIR = path.join(__dirname, "../pages/docs/gentype/latest");
184-
const TARGET_FILE = path.join(__dirname, "../index_data/gentype_toc.json");
184+
const SIDEBAR_JSON = path.join(__dirname, "../data/sidebar_gentype_latest.json");
185+
const TARGET_FILE = path.join(__dirname, "../index_data/gentype_latest_toc.json");
185186

186-
const files = glob.sync(`${MD_DIR}/*.md?(x)`);
187-
const result = files.map(processFile);
187+
const sidebarJson = JSON.parse(fs.readFileSync(SIDEBAR_JSON));
188+
189+
const FILE_ORDER = Object.values(sidebarJson).reduce((acc, items) => {
190+
return acc.concat(items)
191+
},[]);
192+
193+
const files = glob.sync(`${MD_DIR}/*.?(js|md?(x))`);
194+
const ordered = orderFiles(files, FILE_ORDER);
195+
196+
const result = ordered.map((filepath) => processFile(filepath, sidebarJson));
188197
const toc = createTOC(result);
189198

190199
fs.writeFileSync(TARGET_FILE, JSON.stringify(toc), "utf8");
191200
};
192201

193202
const createCommunityToc = () => {
194203
const MD_DIR = path.join(__dirname, "../pages/community");
204+
const SIDEBAR_JSON = path.join(__dirname, "../data/sidebar_community.json");
195205
const TARGET_FILE = path.join(__dirname, "../index_data/community_toc.json");
196206

197-
const files = glob.sync(`${MD_DIR}/*.md?(x)`);
198-
const result = files.map(processFile);
207+
const sidebarJson = JSON.parse(fs.readFileSync(SIDEBAR_JSON));
208+
209+
const FILE_ORDER = Object.values(sidebarJson).reduce((acc, items) => {
210+
return acc.concat(items)
211+
},[]);
212+
213+
const files = glob.sync(`${MD_DIR}/*.?(js|md?(x))`);
214+
const ordered = orderFiles(files, FILE_ORDER);
215+
216+
const result = ordered.map((filepath) => processFile(filepath, sidebarJson));
199217
const toc = createTOC(result);
200218

201219
fs.writeFileSync(TARGET_FILE, JSON.stringify(toc), "utf8");

src/common/App.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)