FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Docs demo by benhalverson · Pull Request #1344 · nodejs/nodejs.dev · GitHub

This repository was archived by the owner on Apr 26, 2024. It is now read-only.
/ nodejs.dev Public archive
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (3) .json  (2) .scss  (1) .tsx  (1) All 4 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions gatsby-config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
32 changes: 32 additions & 0 deletions gatsby-node-docs.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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,
});
});
};
2 changes: 1 addition & 1 deletion gatsby-node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
74 changes: 74 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
62 changes: 62 additions & 0 deletions src/pages/docs-demo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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<string, unknown>;
};
};
}

const DocsLayout = ({ data }: Props): JSX.Element => {
const authors = [''];
return (
<Layout title={title} description={description}>
<main className="docs-container">
<Article
title=""
html={data.doc.edges[105].node.html}
authors={authors}
editPath="node_modules/node-i18n/content/v12.x/en-US/doc/"
/>
{console.log(data)}
</main>
</Layout>
);
};
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
}
}
}
}
`;
3 changes: 2 additions & 1 deletion src/styles/layout.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ details {
}
}

.blog-container {
.blog-container,
.docs-container {
display: flex;
justify-content: center;
}
Expand Down

Back | FazBrowse Home | New Git URL