Skip to content

Commit f52de03

Browse files
committed
Fix sidebar
1 parent 673f443 commit f52de03

26 files changed

+199
-115
lines changed

data/sidebar_react_latest.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Overview": [
3+
"introduction",
4+
"installation"
5+
],
6+
"Main Concepts": [
7+
"elements-and-jsx",
8+
"rendering-elements",
9+
"components-and-props",
10+
"arrays-and-keys",
11+
"refs-and-the-dom",
12+
"context"
13+
],
14+
"Hooks & State Management": [
15+
"hooks-overview",
16+
"hooks-effect",
17+
"hooks-state",
18+
"hooks-reducer",
19+
"hooks-context",
20+
"hooks-ref",
21+
"hooks-custom"
22+
],
23+
"Guides": [
24+
"beyond-jsx",
25+
"forwarding-refs"
26+
]
27+
}

layouts/ReactDocsLayout.re

Lines changed: 0 additions & 69 deletions
This file was deleted.

pages/docs/react/latest/arrays-and-keys.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Arrays and Keys
33
description: "Rendering arrays and handling keys in ReScript and React"
44
canonical: "/docs/react/latest/arrays-and-keys"
5-
category: "Main Concepts"
65
---
76

87
# Arrays and Keys

pages/docs/react/latest/beyond-jsx.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Beyond JSX
33
description: "Details on how to use ReScript and React without JSX"
44
canonical: "/docs/react/latest/beyond-jsx"
5-
category: "Guides"
65
---
76

87
# Beyond JSX

pages/docs/react/latest/components-and-props.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Components and Props
33
description: "Basic concepts for components and props in ReasonReact"
44
canonical: "/docs/react/latest/components-and-props"
5-
category: "Main Concepts"
65
---
76

87
# Components and Props

pages/docs/react/latest/context.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Context
33
description: "Details about Context in ReScript and React"
44
canonical: "/docs/react/latest/context"
5-
category: "Main Concepts"
65
---
76

87
# Context

pages/docs/react/latest/elements-and-jsx.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Elements & JSX
33
description: "Basic concepts for React elements and how to use them in JSX"
44
canonical: "/docs/react/latest/elements-and-jsx"
5-
category: "Main Concepts"
65
---
76

87
# Elements & JSX

pages/docs/react/latest/forwarding-refs.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Forwarding Refs
33
description: "Forwarding Ref values in ReScript and React"
44
canonical: "/docs/react/latest/forwarding-refs"
5-
category: "Guides"
65
---
76

87
# Forwarding Refs

pages/docs/react/latest/hooks-context.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: useContext Hook
33
description: "Details about the useContext React hook in ReScript"
44
canonical: "/docs/react/latest/hooks-context"
5-
category: "Hooks & State Management"
65
---
76

87
# useContext

pages/docs/react/latest/hooks-custom.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Build A Custom Hook
33
description: "How to build your own hooks in ReScript & React"
44
canonical: "/docs/react/latest/hooks-custom"
5-
category: "Hooks & State Management"
65
---
76

87
# Build A Custom Hook

pages/docs/react/latest/hooks-effect.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: useEffect Hook
33
description: "Details about the useEffect React hook in ReScript"
44
canonical: "/docs/react/latest/hooks-effect"
5-
category: "Hooks & State Management"
65
---
76

87
# useEffect

pages/docs/react/latest/hooks-overview.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Hooks & State Management Overview
33
description: "Overview state management and hooks in ReScript and React"
44
canonical: "/docs/react/latest/hooks-overview"
5-
category: "Hooks & State Management"
65
---
76

87
# Hooks Overview

pages/docs/react/latest/hooks-reducer.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: useReducer Hook
33
description: "Details about the useReducer React hook in ReScript"
44
canonical: "/docs/react/latest/hooks-reducer"
5-
category: "Hooks & State Management"
65
---
76

87
# useReducer

pages/docs/react/latest/hooks-ref.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: useRef Hook
33
description: "Details about the useRef React hook in ReScript"
44
canonical: "/docs/react/latest/hooks-ref"
5-
category: "Hooks & State Management"
65
---
76

87
# useRef

pages/docs/react/latest/hooks-state.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: useState Hook
33
description: "Details about the useState React hook in ReScript"
44
canonical: "/docs/react/latest/hooks-state"
5-
category: "Hooks & State Management"
65
---
76

87
# useState

pages/docs/react/latest/installation.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Installation
33
description: "Installation and Setup"
44
canonical: "/docs/react/latest/installation"
5-
category: Overview
65
---
76

87
# Installation

pages/docs/react/latest/introduction.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Introduction
33
description: "Introduction to ReScript & ReactJS"
44
canonical: "/docs/react/latest/introduction"
5-
category: Overview
65
---
76

87
# Introduction

pages/docs/react/latest/refs-and-the-dom.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Refs and the DOM
33
description: "Using Refs and DOM elements in ReScript and React"
44
canonical: "/docs/react/latest/refs-and-the-dom"
5-
category: "Main Concepts"
65
---
76

87
# Refs and the DOM

pages/docs/react/latest/rendering-elements.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Rendering Elements
33
description: "How to render React elements to the DOM"
44
canonical: "/docs/react/latest/rendering-elements"
5-
category: "Main Concepts"
65
---
76

87
# Rendering Elements

scripts/extract-tocs.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,29 +182,19 @@ const createV800ManualToc = () => {
182182

183183
const createReactToc = () => {
184184
const MD_DIR = path.join(__dirname, "../pages/docs/react/latest");
185+
const SIDEBAR_JSON = path.join(__dirname, "../data/sidebar_react_latest.json");
185186
const TARGET_FILE = path.join(__dirname, "../index_data/react_latest_toc.json");
186187

187-
const FILE_ORDER = [
188-
"introduction",
189-
"installation",
190-
"elements-and-jsx",
191-
"rendering-elements",
192-
"components-and-props",
193-
"arrays-and-keys",
194-
"refs-and-the-dom",
195-
"hooks-overview",
196-
"hooks-state",
197-
"hooks-reducer",
198-
"hooks-effect",
199-
"hooks-context",
200-
"hooks-ref",
201-
"hooks-custom",
202-
];
188+
const sidebarJson = JSON.parse(fs.readFileSync(SIDEBAR_JSON));
189+
190+
const FILE_ORDER = Object.values(sidebarJson).reduce((acc, items) => {
191+
return acc.concat(items)
192+
},[]);
203193

204194
const files = glob.sync(`${MD_DIR}/*.md?(x)`);
205195
const ordered = orderFiles(files, FILE_ORDER);
206196

207-
const result = ordered.map(processFile);
197+
const result = ordered.map((filepath) => processFile(filepath, sidebarJson));
208198
const toc = createTOC(result);
209199

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

src/DocsOverview.js

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

src/DocsOverview.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let default = (~showVersionSelect=true) => {
3636
let ecosystem = [
3737
("Package Index", "/packages"),
3838
("GenType", "/docs/gentype/latest/introduction"),
39-
("ReasonReact", "https://reasonml.github.io/reason-react"),
39+
("rescript-react", "/docs/react/latest/introduction"),
4040
("Reanalyze", "https://github.com/reason-association/reanalyze"),
4141
]
4242
let tools = [("Syntax Lookup", "/syntax-lookup")]

src/common/App.js

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

src/common/App.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ let make = (props: props): React.element => {
9292
| _ => React.null
9393
}
9494
}
95+
| {base: ["docs", "react"], version: Latest} =>
96+
<ReactDocsLayout frontmatter={component->frontmatter}> content </ReactDocsLayout>
9597
| {base: ["docs", "reason-compiler"], version: Latest} =>
9698
<ReasonCompilerDocsLayout> content </ReasonCompilerDocsLayout>
9799
| {base: ["docs", "gentype"], version: Latest} =>

0 commit comments

Comments
 (0)