Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
feat(docs): introduced initial version of api docs system (#2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovflowd authored Sep 2, 2022
1 parent 62403e6 commit 7014d9d
Show file tree
Hide file tree
Showing 127 changed files with 8,194 additions and 10,692 deletions.
32 changes: 32 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"generatorOpts": {
"compact": true,
"comments": false
},
"overrides": [
{
"test": "**/**.md",
"compact": true
}
],
"plugins": [
[
"prismjs",
{
"languages": ["js", "css", "jsx", "bash", "ts", "markup", "cpp", "c"],
"plugins": [],
"css": false
}
]
],
"presets": [
[
"babel-preset-gatsby",
{
"targets": {
"browsers": ["last 3 versions", "not ie <= 11", "not android 4.4.3"]
}
}
]
]
}
10 changes: 10 additions & 0 deletions apiUrls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
apiReleaseContents: releaseVersion =>
`https://api.github.com/repos/nodejs/node/contents/doc/api?ref=${releaseVersion}`,
nvmTags: 'https://api.github.com/repos/nvm-sh/nvm/tags',
nodeReleaseSchedule:
'https://raw.githubusercontent.com/nodejs/Release/main/schedule.json',
nodeReleaseData: 'https://nodejs.org/dist/index.json',
nodeBannersData:
'https://raw.githubusercontent.com/nodejs/nodejs.org/main/locale/en/site.json',
};
2 changes: 1 addition & 1 deletion content/learn/node-introduction.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The most common example Hello World of Node.js is a web server:
style="height: 400px; width: 100%; border: 0;">
</iframe>

<!--```js
```js
const http = require('http')

const hostname = '127.0.0.1'
Expand Down
5 changes: 0 additions & 5 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
}
],
"redirects": [
{
"source": "/en/get-involved/",
"destination": "/community/",
"type": "301"
},
{
"source": "/get-involved/",
"destination": "/community/",
Expand Down
80 changes: 56 additions & 24 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path');

require('dotenv').config();

const config = require('./src/config.json');
Expand All @@ -21,7 +23,6 @@ const gatsbyConfig = {
'gatsby-plugin-catch-links',
'@skagami/gatsby-plugin-dark-mode',
'gatsby-transformer-yaml',
'gatsby-remark-images',
'gatsby-plugin-sharp',
{
resolve: 'gatsby-plugin-canonical-urls',
Expand All @@ -44,68 +45,65 @@ const gatsbyConfig = {
resolve: 'gatsby-source-filesystem',
options: {
name: 'learn',
path: `${__dirname}/content/learn`,
path: path.resolve('./content/learn'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'sites',
path: `${__dirname}/src/pages/`,
path: path.resolve('./src/pages'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'homepage',
path: `${__dirname}/content/homepage`,
path: path.resolve('./content/homepage'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'community',
path: `${__dirname}/content/community`,
path: path.resolve('./content/community'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'blog',
path: `${__dirname}/content/blog`,
path: path.resolve('./content/blog'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'data',
path: `${__dirname}/src/data`,
path: path.resolve('./src/data'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'about',
path: `${__dirname}/content/about`,
path: path.resolve('./content/about'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'download',
path: `${__dirname}/content/download`,
path: path.resolve('./content/download'),
},
},
'gatsby-plugin-typescript',
{
resolve: 'gatsby-plugin-mdx',
options: {
extensions: ['.mdx', '.md'],
defaultLayouts: {
default: require.resolve(`./src/components/Layout/index.tsx`),
},
gatsbyRemarkPlugins: [
'gatsby-remark-copy-linked-files',
{ resolve: 'gatsby-remark-copy-linked-files' },
{
resolve: 'gatsby-remark-autolink-headers',
options: {
Expand Down Expand Up @@ -138,17 +136,30 @@ const gatsbyConfig = {
{
resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
options: {
fields: [`title`, `body`, `description`, `slug`],
fields: [
'slug',
'title',
'displayTitle',
'description',
'category',
'tableOfContents',
],
resolvers: {
Mdx: {
id: node => node.id,
title: node => node.frontmatter.title,
body: node => node.rawBody,
displayTitle: node => node.frontmatter.displayTitle,
description: node => node.frontmatter.description,
slug: node => node.fields.slug,
category: node => node.fields.categoryName,
tableOfContents: node => {
return [...node.rawBody.matchAll(/^#{2,5} .*/gm)]
.map(match => match[0].replace(/^#{2,5} /, ''))
.join('\n');
},
},
},
filter: node => node.frontmatter.category === 'learn',
filter: node => ['api', 'learn'].includes(node.frontmatter.category),
},
},
{
Expand All @@ -158,11 +169,39 @@ const gatsbyConfig = {
resolve: `gatsby-theme-i18n`,
options: {
defaultLang: defaultLanguage,
configPath: `${__dirname}/src/i18n/config.json`,
configPath: path.resolve('./src/i18n/config.json'),
prefixDefault: true,
locales: localesAsString,
},
},
{
resolve: `gatsby-plugin-webfonts`,
options: {
fonts: {
google: [
{
family: 'Open Sans',
variants: [
'300',
'300i',
'400',
'400i',
'600',
'600i',
'900',
'900i',
],
fontDisplay: 'swap',
strategy: 'selfHosted',
},
],
},
formats: ['woff2'],
useMinify: true,
usePreload: true,
usePreconnect: true,
},
},
{
resolve: 'gatsby-plugin-manifest',
options: {
Expand Down Expand Up @@ -191,13 +230,6 @@ if (!gatsbyConfig.pathPrefix) {
// So we are able to use the official service worker again. This service worker supports latest Workbox
resolve: 'gatsby-plugin-offline-next',
options: {
precachePages: [
'/',
'/*/learn/*',
'/*/about/*',
'/*/download/*',
'/*/blog/*',
],
globPatterns: ['**/icon-path*'],
},
});
Expand Down
Loading

0 comments on commit 7014d9d

Please sign in to comment.