versionSelect
diff --git a/scripts/extract-tocs.js b/scripts/extract-tocs.js
index 357f1bd5e..d77e8b83b 100644
--- a/scripts/extract-tocs.js
+++ b/scripts/extract-tocs.js
@@ -11,6 +11,21 @@ const glob = require("glob");
const path = require("path");
const fs = require("fs");
+// orderArr: ["introduction", "overview",,...]
+const orderFiles = (filepaths, orderArr) => {
+ const order = orderArr.reduce((acc, next, i) => {
+ acc[next] = null;
+ return acc;
+ }, {});
+
+ filepaths.forEach((filepath) => {
+ const id = path.basename(filepath, path.extname(filepath));
+ order[id] = filepath;
+ });
+
+ return Object.values(order);
+};
+
// Used for collapsing nested inlineCodes with the actual header text
const collapseHeaderChildren = (children) => {
return children.reduce((acc, node) => {
@@ -63,11 +78,18 @@ const processFile = filepath => {
const parsedPath = path.parse(relFilepath);
const filename = path.basename(filepath, path.extname(filepath));
+ let title = result.data.mainHeader || data.title || filename;
+
const dataset = {
+ id: filename,
headers: result.data.headers,
href: path.join(parsedPath.dir, parsedPath.name),
- title: result.data.mainHeader || filename
+ title,
};
+
+ if(data.category != null) {
+ dataset.category = data.category;
+ }
return dataset;
};
@@ -76,10 +98,12 @@ const createTOC = result => {
// reflected as the router pathname, as defined by the
// NextJS router
return result.reduce((acc, data) => {
- const { title, headers } = data;
+ const { title, headers, category, id } = data;
acc["/" + data.href] = {
+ id,
title,
- headers
+ headers,
+ category,
};
return acc;
@@ -119,12 +143,32 @@ const createV800ManualToc = () => {
fs.writeFileSync(TARGET_FILE, JSON.stringify(toc), "utf8");
};
-const createReasonReactToc = () => {
- const MD_DIR = path.join(__dirname, "../pages/docs/reason-react/latest");
- const TARGET_FILE = path.join(__dirname, "../index_data/reason_react_toc.json");
+
+const createReactToc = () => {
+ const MD_DIR = path.join(__dirname, "../pages/docs/react/latest");
+ 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 files = glob.sync(`${MD_DIR}/*.md?(x)`);
- const result = files.map(processFile);
+ const ordered = orderFiles(files, FILE_ORDER);
+
+ const result = ordered.map(processFile);
const toc = createTOC(result);
fs.writeFileSync(TARGET_FILE, JSON.stringify(toc), "utf8");
@@ -171,6 +215,6 @@ debugToc();
createLatestManualToc();
createV800ManualToc();
createReasonCompilerToc();
-createReasonReactToc();
+createReactToc();
createGenTypeToc();
createCommunityToc();
diff --git a/styles/_hljs.css b/styles/_hljs.css
index b39841336..988b72aee 100644
--- a/styles/_hljs.css
+++ b/styles/_hljs.css
@@ -114,10 +114,6 @@ Docco style used in http://jashkenas.github.com/docco/ converted by Simon Madine
/*@apply text-code-1;*/
}
-.hljs-line-highlight {
- @apply w-full inline-block bg-berry-15;
-}
-
/* DARK MODE COLORS */
.hljs.dark .hljs-comment {
diff --git a/styles/_markdown.css b/styles/_markdown.css
index fa8c7b80c..1dc368127 100644
--- a/styles/_markdown.css
+++ b/styles/_markdown.css
@@ -1,7 +1,7 @@
/* Markdown related stuff */
/* Sometimes we cannot circumvent the cascade, especially for nested lists */
-.md-ul {
+.md-ul, .md-ol {
@apply mb-4;
}
diff --git a/yarn.lock b/yarn.lock
index a46dca976..050bc4672 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5809,7 +5809,7 @@ randomfill@^1.0.3:
randombytes "^2.0.5"
safe-buffer "^5.1.0"
-react-dom@>=16.8.1, react-dom@^16.12.0:
+react-dom@^16.12.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.13.1.tgz#c1bd37331a0486c078ee54c4740720993b2e0e7f"
integrity sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==
@@ -5829,7 +5829,7 @@ react-refresh@0.8.3:
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f"
integrity sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==
-react@>=16.8.1, react@^16.12.0:
+react@^16.12.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e"
integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==
@@ -5893,13 +5893,10 @@ reason-promise@^1.0.2:
resolved "https://registry.yarnpkg.com/reason-promise/-/reason-promise-1.1.1.tgz#966133fed21e748a50ffb8839a1da04912bcf380"
integrity sha512-xMXDiyzTjn7t9pq9aQrkgu8CLB5DILU70oWQ+LI20YecshypUwsw37TKOvCxgoFR3vo30ucF0/iWe2BZ181/jw==
-reason-react@^0.7.0:
- version "0.7.1"
- resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.7.1.tgz#e6acea88542cd44398cd980093b8a2ab2722744e"
- integrity sha512-Ssx4jZYohMHW9ZiW893IfbYdZw/muSmPFKigAgL+AORUgyiaphb0PP4yRGlx9A7JAxR3EeBn294XKUaClJQhbA==
- dependencies:
- react ">=16.8.1"
- react-dom ">=16.8.1"
+reason-react@^0.9.1:
+ version "0.9.1"
+ resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.9.1.tgz#30a887158200b659aa03e2d75ff4cc54dc462bb0"
+ integrity sha512-nlH0O2TDy9KzOLOW+vlEQk4ExHOeciyzFdoLcsmmiit6hx6H5+CVDrwJ+8aiaLT/kqK5xFOjy4PS7PftWz4plA==
reduce-css-calc@^2.1.6:
version "2.1.7"