Skip to content

New react docs (only content) #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix sidebar
  • Loading branch information
ryyppy committed Jan 27, 2021
commit f52de034d23d6032464f4d84914a7cd9c9c69411
27 changes: 27 additions & 0 deletions data/sidebar_react_latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"Overview": [
"introduction",
"installation"
],
"Main Concepts": [
"elements-and-jsx",
"rendering-elements",
"components-and-props",
"arrays-and-keys",
"refs-and-the-dom",
"context"
],
"Hooks & State Management": [
"hooks-overview",
"hooks-effect",
"hooks-state",
"hooks-reducer",
"hooks-context",
"hooks-ref",
"hooks-custom"
],
"Guides": [
"beyond-jsx",
"forwarding-refs"
]
}
69 changes: 0 additions & 69 deletions layouts/ReactDocsLayout.re

This file was deleted.

1 change: 0 additions & 1 deletion pages/docs/react/latest/arrays-and-keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Arrays and Keys
description: "Rendering arrays and handling keys in ReScript and React"
canonical: "/docs/react/latest/arrays-and-keys"
category: "Main Concepts"
---

# Arrays and Keys
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/beyond-jsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Beyond JSX
description: "Details on how to use ReScript and React without JSX"
canonical: "/docs/react/latest/beyond-jsx"
category: "Guides"
---

# Beyond JSX
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/components-and-props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Components and Props
description: "Basic concepts for components and props in ReasonReact"
canonical: "/docs/react/latest/components-and-props"
category: "Main Concepts"
---

# Components and Props
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Context
description: "Details about Context in ReScript and React"
canonical: "/docs/react/latest/context"
category: "Main Concepts"
---

# Context
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/elements-and-jsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Elements & JSX
description: "Basic concepts for React elements and how to use them in JSX"
canonical: "/docs/react/latest/elements-and-jsx"
category: "Main Concepts"
---

# Elements & JSX
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/forwarding-refs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Forwarding Refs
description: "Forwarding Ref values in ReScript and React"
canonical: "/docs/react/latest/forwarding-refs"
category: "Guides"
---

# Forwarding Refs
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/hooks-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: useContext Hook
description: "Details about the useContext React hook in ReScript"
canonical: "/docs/react/latest/hooks-context"
category: "Hooks & State Management"
---

# useContext
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/hooks-custom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Build A Custom Hook
description: "How to build your own hooks in ReScript & React"
canonical: "/docs/react/latest/hooks-custom"
category: "Hooks & State Management"
---

# Build A Custom Hook
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/hooks-effect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: useEffect Hook
description: "Details about the useEffect React hook in ReScript"
canonical: "/docs/react/latest/hooks-effect"
category: "Hooks & State Management"
---

# useEffect
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/hooks-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Hooks & State Management Overview
description: "Overview state management and hooks in ReScript and React"
canonical: "/docs/react/latest/hooks-overview"
category: "Hooks & State Management"
---

# Hooks Overview
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/hooks-reducer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: useReducer Hook
description: "Details about the useReducer React hook in ReScript"
canonical: "/docs/react/latest/hooks-reducer"
category: "Hooks & State Management"
---

# useReducer
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/hooks-ref.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: useRef Hook
description: "Details about the useRef React hook in ReScript"
canonical: "/docs/react/latest/hooks-ref"
category: "Hooks & State Management"
---

# useRef
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/hooks-state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: useState Hook
description: "Details about the useState React hook in ReScript"
canonical: "/docs/react/latest/hooks-state"
category: "Hooks & State Management"
---

# useState
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Installation
description: "Installation and Setup"
canonical: "/docs/react/latest/installation"
category: Overview
---

# Installation
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Introduction
description: "Introduction to ReScript & ReactJS"
canonical: "/docs/react/latest/introduction"
category: Overview
---

# Introduction
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/refs-and-the-dom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Refs and the DOM
description: "Using Refs and DOM elements in ReScript and React"
canonical: "/docs/react/latest/refs-and-the-dom"
category: "Main Concepts"
---

# Refs and the DOM
Expand Down
1 change: 0 additions & 1 deletion pages/docs/react/latest/rendering-elements.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Rendering Elements
description: "How to render React elements to the DOM"
canonical: "/docs/react/latest/rendering-elements"
category: "Main Concepts"
---

# Rendering Elements
Expand Down
24 changes: 7 additions & 17 deletions scripts/extract-tocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,29 +182,19 @@ const createV800ManualToc = () => {

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

const FILE_ORDER = [
"introduction",
"installation",
"elements-and-jsx",
"rendering-elements",
"components-and-props",
"arrays-and-keys",
"refs-and-the-dom",
"hooks-overview",
"hooks-state",
"hooks-reducer",
"hooks-effect",
"hooks-context",
"hooks-ref",
"hooks-custom",
];
const sidebarJson = JSON.parse(fs.readFileSync(SIDEBAR_JSON));

const FILE_ORDER = Object.values(sidebarJson).reduce((acc, items) => {
return acc.concat(items)
},[]);

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

const result = ordered.map(processFile);
const result = ordered.map((filepath) => processFile(filepath, sidebarJson));
const toc = createTOC(result);

fs.writeFileSync(TARGET_FILE, JSON.stringify(toc), "utf8");
Expand Down
4 changes: 2 additions & 2 deletions src/DocsOverview.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/DocsOverview.res
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let default = (~showVersionSelect=true) => {
let ecosystem = [
("Package Index", "/packages"),
("GenType", "/docs/gentype/latest/introduction"),
("ReasonReact", "https://reasonml.github.io/reason-react"),
("rescript-react", "/docs/react/latest/introduction"),
("Reanalyze", "https://github.com/reason-association/reanalyze"),
]
let tools = [("Syntax Lookup", "/syntax-lookup")]
Expand Down
33 changes: 24 additions & 9 deletions src/common/App.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/common/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ let make = (props: props): React.element => {
| _ => React.null
}
}
| {base: ["docs", "react"], version: Latest} =>
<ReactDocsLayout frontmatter={component->frontmatter}> content </ReactDocsLayout>
| {base: ["docs", "reason-compiler"], version: Latest} =>
<ReasonCompilerDocsLayout> content </ReasonCompilerDocsLayout>
| {base: ["docs", "gentype"], version: Latest} =>
Expand Down
Loading