Skip to content

Commit b6fab6d

Browse files
committed
feat(docs): use doc-kit 1.3.0
1 parent d699f9b commit b6fab6d

76 files changed

Lines changed: 244 additions & 544 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
node_modules
22
out
3-
components/config.json

.remarkrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"plugins": ["@node-core/remark-lint"]
2+
"plugins": ["remark-frontmatter", "@node-core/remark-lint"]
33
}

components/Layout/index.jsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import TableOfContents from '@node-core/ui-components/Common/TableOfContents';
2+
import Article from '@node-core/ui-components/Containers/Article';
3+
4+
import NavBar from '../Navigation';
5+
import MetaBar from '../Metabar';
6+
7+
import Footer from '#theme/Footer';
8+
import SideBar from '#theme/Sidebar';
9+
10+
/**
11+
* @typedef {Object} Props
12+
* @property {import('@node-core/doc-kit/src/generators/web/ui/types.d.ts').SerializedMetadata} metadata
13+
* @property {Array} headings
14+
* @property {string} readingTime
15+
* @property {import('preact').ComponentChildren} children
16+
*/
17+
18+
/**
19+
* @param {Props} props
20+
*/
21+
export default ({ metadata, headings, readingTime, children }) => (
22+
<>
23+
<NavBar />
24+
<Article>
25+
<SideBar metadata={metadata} />
26+
<div>
27+
<div>
28+
<TableOfContents headings={headings} summaryTitle="On this page" />
29+
<br />
30+
<main>{children}</main>
31+
</div>
32+
<MetaBar
33+
metadata={metadata}
34+
headings={headings}
35+
readingTime={readingTime}
36+
/>
37+
</div>
38+
</Article>
39+
<Footer />
40+
</>
41+
);

components/Metabar/index.jsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,27 @@ import MetaBar from '@node-core/ui-components/Containers/MetaBar';
22
import AvatarGroup from '@node-core/ui-components/Common/AvatarGroup';
33
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
44

5-
import { authors } from '../config.json' with { type: 'json' };
5+
import { editURL } from '#theme/config';
66

7-
/**
8-
* @typedef MetaBarProps
9-
* @property {Array<import('@vcarl/remark-headings').Heading>} headings
10-
* @property {string} readingTime
11-
* @property {Array<[string, string]>} viewAs
12-
* @property {string} editThisPage
13-
*/
14-
15-
/** @param {MetaBarProps} props */
16-
export default ({ headings = [], readingTime, viewAs = [], editThisPage }) => {
17-
const pageAuthors = authors[editThisPage];
7+
/** @param {import('../Layout').Props} props */
8+
export default ({ metadata, headings = [], readingTime }) => {
9+
const editThisPage = editURL.replace('{path}', metadata.path);
10+
const authors = metadata.authors?.split(',').map(id => ({
11+
image: `https://avatars.githubusercontent.com/${id.trim()}`,
12+
url: `https://github.com/${id.trim()}`,
13+
nickname: id,
14+
}));
1815

1916
return (
2017
<MetaBar
2118
heading="Table of Contents"
2219
headings={{ items: headings }}
2320
items={{
2421
'Reading Time': readingTime,
25-
...(CLIENT && pageAuthors?.length
22+
...(CLIENT && authors?.length
2623
? {
2724
Authors: (
28-
<AvatarGroup avatars={pageAuthors} as="a" clickable limit={5} />
25+
<AvatarGroup avatars={authors} as="a" limit={5} />
2926
),
3027
}
3128
: {}),

components/Navigation/index.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import SearchBox from '@node-core/doc-kit/src/generators/web/ui/components/Searc
77
import { useTheme } from '@node-core/doc-kit/src/generators/web/ui/hooks/useTheme.mjs';
88

99
import Logo from '#theme/Logo';
10-
import { topNav } from '../config.json' with { type: 'json' };
1110

1211
/**
1312
* NavBar component that displays the headings, search, etc.
@@ -19,7 +18,7 @@ export default () => {
1918
<NavBar
2019
Logo={Logo}
2120
sidebarItemTogglerAriaLabel="Toggle navigation menu"
22-
navItems={topNav}
21+
navItems={[]}
2322
>
2423
<SearchBox />
2524
<ThemeToggle

components/Sidebar/index.jsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

doc-kit.config.mjs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,13 @@ export default {
77
output: 'out',
88
input: ['pages/**/*.md'],
99
},
10-
'jsx-ast': {
11-
// TODO(@avivkeller): Hook this up to render at nodejs.org/learn
12-
pageURL: 'https://nodejs.github.io/learn{path}.html',
13-
editURL: 'https://github.com/nodejs/learn/edit/main/pages{path}.md',
14-
},
1510
web: {
1611
title: '',
12+
pageURL: 'https://nodejs.org/learn{path}.html',
13+
editURL: 'https://github.com/nodejs/learn/edit/main/pages{path}.md',
1714
imports: {
1815
...web.defaultConfiguration.imports,
19-
'#theme/Navigation': join(
20-
import.meta.dirname,
21-
'components/Navigation/index.jsx'
22-
),
23-
'#theme/Sidebar': join(
24-
import.meta.dirname,
25-
'components/Sidebar/index.jsx'
26-
),
27-
'#theme/Metabar': join(
28-
import.meta.dirname,
29-
'components/Metabar/index.jsx'
30-
),
16+
'#theme/Layout': join(import.meta.dirname, 'components/Layout/index.jsx'),
3117
},
3218
},
3319
};

package-lock.json

Lines changed: 95 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"scripts": {
3-
"prebuild": "node scripts/generate-component-config.mjs",
43
"build": "doc-kit generate -t web -t orama-db --config-file doc-kit.config.mjs",
54
"lint": "eslint .",
65
"lint:fix": "eslint --fix .",
@@ -10,14 +9,15 @@
109
},
1110
"devDependencies": {
1211
"@eslint/js": "^10.0.1",
13-
"@node-core/doc-kit": "1.2.1",
12+
"@node-core/doc-kit": "1.3.0",
1413
"@node-core/remark-lint": "^1.3.0",
1514
"eslint": "^10.1.0",
1615
"eslint-plugin-mdx": "^3.7.0",
1716
"globals": "^17.4.0",
1817
"husky": "^9.1.7",
1918
"lint-staged": "^16.4.0",
2019
"prettier": "^3.8.1",
20+
"remark-frontmatter": "^5.0.0",
2121
"typescript-eslint": "^8.57.2"
2222
},
2323
"dependencies": {

pages/asynchronous-work/asynchronous-flow-control.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<!-- YAML
1+
---
22
authors: aug2uag, ovflowd
3-
-->
3+
---
44

55
# Asynchronous flow control
66

0 commit comments

Comments
 (0)