diff --git a/gatsby-config.js b/gatsby-config.js index 74c8ac01ec..9e385a354d 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -76,6 +76,13 @@ module.exports = { path: `${__dirname}/content/about`, }, }, + { + resolve: 'gatsby-source-git', + options: { + name: 'markdown-docs', + path: './node_modules/node-i18n/content/v12.x/en-US/doc/api', + }, + }, { resolve: `gatsby-plugin-mdx`, options: { diff --git a/gatsby-node-docs.js b/gatsby-node-docs.js new file mode 100644 index 0000000000..61d74dfade --- /dev/null +++ b/gatsby-node-docs.js @@ -0,0 +1,32 @@ +exports.createPages = async ({ actions, graphql, reporter }) => { + const { createPage } = actions; + + const docsTemplate = require.resolve(`./src/templates/docs.tsx`); + + const result = await graphql(` + { + allMarkdownRemark { + edges { + node { + excerpt + fileAbsolutePath + } + } + } + } + `); + + // Handle errors + if (result.errors) { + reporter.panicOnBuild(`Error while running GraphQL query.`); + return; + } + + result.data.allMarkdownRemark.edges.forEach(node => { + createPage({ + path: node.frontmatter.slug, + // path: 'test', + component: docsTemplate, + }); + }); +}; diff --git a/gatsby-node.js b/gatsby-node.js index 3e4064dbc0..5bc8a4dee7 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -3,7 +3,7 @@ const path = require('path'); const fetch = require('node-fetch'); const createSlug = require('./util-node/createSlug'); const getReleaseStatus = require('./util-node/getReleaseStatus'); - +require('./gatsby-node-docs'); const BLOG_POST_FILENAME_REGEX = /([0-9]+)-([0-9]+)-([0-9]+)-(.+)\.md$/; exports.createPages = ({ graphql, actions }) => { diff --git a/package-lock.json b/package-lock.json index 08b7729615..24a655638b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,6 +46,7 @@ "gatsby-transformer-yaml": "^3.4.0", "intersection-observer": "^0.12.0", "node-fetch": "^2.6.1", + "node-i18n": "github:nodejs/i18n", "prismjs": "^1.23.0", "react": "^16.13.1", "react-dom": "^16.13.1", @@ -19156,6 +19157,11 @@ "node": ">=6" } }, + "node_modules/ensure-posix-path": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ensure-posix-path/-/ensure-posix-path-1.1.1.tgz", + "integrity": "sha512-VWU0/zXzVbeJNXvME/5EmLuEj2TauvoaTz6aFYK1Z92JCBlDlZ3Gu0tuGR42kpW1754ywTs+QB0g5TP0oj9Zaw==" + }, "node_modules/entities": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", @@ -33952,6 +33958,18 @@ "react": ">= 0.14.0" } }, + "node_modules/matcher-collection": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-2.0.1.tgz", + "integrity": "sha512-daE62nS2ZQsDg9raM0IlZzLmI2u+7ZapXBwdoeBUKAYERPDDIc0qNqA8E0Rp2D+gspKR7BgIFP52GeujaGXWeQ==", + "dependencies": { + "@types/minimatch": "^3.0.3", + "minimatch": "^3.0.2" + }, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, "node_modules/md5-file": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/md5-file/-/md5-file-5.0.0.tgz", @@ -35419,6 +35437,15 @@ "node": ">=10" } }, + "node_modules/node-i18n": { + "version": "1.0.0", + "resolved": "git+ssh://git@github.com/nodejs/i18n.git#19c985c75298711d7da4227d88d8d3f4d61d6a40", + "license": "MIT", + "dependencies": { + "lodash": "^4.17.21", + "walk-sync": "^3.0.0" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -45966,6 +45993,20 @@ "node": ">=10" } }, + "node_modules/walk-sync": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-3.0.0.tgz", + "integrity": "sha512-41TvKmDGVpm2iuH7o+DAOt06yyu/cSHpX3uzAwetzASvlNtVddgIjXIb2DfB/Wa20B1Jo86+1Dv1CraSU7hWdw==", + "dependencies": { + "@types/minimatch": "^3.0.4", + "ensure-posix-path": "^1.1.0", + "matcher-collection": "^2.0.1", + "minimatch": "^3.0.4" + }, + "engines": { + "node": "10.* || >= 12.*" + } + }, "node_modules/walker": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz", @@ -62825,6 +62866,11 @@ } } }, + "ensure-posix-path": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ensure-posix-path/-/ensure-posix-path-1.1.1.tgz", + "integrity": "sha512-VWU0/zXzVbeJNXvME/5EmLuEj2TauvoaTz6aFYK1Z92JCBlDlZ3Gu0tuGR42kpW1754ywTs+QB0g5TP0oj9Zaw==" + }, "entities": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", @@ -74124,6 +74170,15 @@ "unquote": "^1.1.0" } }, + "matcher-collection": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-2.0.1.tgz", + "integrity": "sha512-daE62nS2ZQsDg9raM0IlZzLmI2u+7ZapXBwdoeBUKAYERPDDIc0qNqA8E0Rp2D+gspKR7BgIFP52GeujaGXWeQ==", + "requires": { + "@types/minimatch": "^3.0.3", + "minimatch": "^3.0.2" + } + }, "md5-file": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/md5-file/-/md5-file-5.0.0.tgz", @@ -75234,6 +75289,14 @@ } } }, + "node-i18n": { + "version": "git+ssh://git@github.com/nodejs/i18n.git#19c985c75298711d7da4227d88d8d3f4d61d6a40", + "from": "node-i18n@github:nodejs/i18n", + "requires": { + "lodash": "^4.17.21", + "walk-sync": "^3.0.0" + } + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -83307,6 +83370,17 @@ "xml-name-validator": "^3.0.0" } }, + "walk-sync": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-3.0.0.tgz", + "integrity": "sha512-41TvKmDGVpm2iuH7o+DAOt06yyu/cSHpX3uzAwetzASvlNtVddgIjXIb2DfB/Wa20B1Jo86+1Dv1CraSU7hWdw==", + "requires": { + "@types/minimatch": "^3.0.4", + "ensure-posix-path": "^1.1.0", + "matcher-collection": "^2.0.1", + "minimatch": "^3.0.4" + } + }, "walker": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz", diff --git a/package.json b/package.json index 119f390eaa..e27f5f69ae 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "gatsby-transformer-yaml": "^3.4.0", "intersection-observer": "^0.12.0", "node-fetch": "^2.6.1", + "node-i18n": "github:nodejs/i18n", "prismjs": "^1.23.0", "react": "^16.13.1", "react-dom": "^16.13.1", diff --git a/src/pages/docs-demo.tsx b/src/pages/docs-demo.tsx new file mode 100644 index 0000000000..63a2648ee0 --- /dev/null +++ b/src/pages/docs-demo.tsx @@ -0,0 +1,62 @@ +import { graphql } from 'gatsby'; +import React from 'react'; +import Article from '../components/Article'; +import Layout from '../components/Layout'; + +const title = 'Download Node.js'; +const description = 'Come get me!'; + +interface Props { + data: { + doc: { + edges: string[] | Record; + }; + }; +} + +const DocsLayout = ({ data }: Props): JSX.Element => { + const authors = ['']; + return ( + +
+
+ {console.log(data)} +
+
+ ); +}; +export default DocsLayout; + +export const query = graphql` + { + doc: allMarkdownRemark { + edges { + node { + fileAbsolutePath + frontmatter { + title + } + html + tableOfContents(absolute: true, pathToSlugField: "frontmatter.path") + } + } + } + allFile( + filter: { + absolutePath: { eq: "node_modules/node-i18n/content/v12.x/en-US/doc/" } + } + ) { + edges { + node { + id + absolutePath + } + } + } + } +`; diff --git a/src/styles/layout.scss b/src/styles/layout.scss index 60ea303ad8..c6185264ab 100644 --- a/src/styles/layout.scss +++ b/src/styles/layout.scss @@ -548,7 +548,8 @@ details { } } -.blog-container { +.blog-container, +.docs-container { display: flex; justify-content: center; }