Skip to content

Commit 3c1848b

Browse files
committed
feat(docs): use doc-kit 1.3.0
1 parent 43879e3 commit 3c1848b

76 files changed

Lines changed: 280 additions & 535 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+
import SideBar from '../Sidebar';
7+
8+
import Footer from '#theme/Footer';
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 & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,26 @@ 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
? {
27-
Authors: (
28-
<AvatarGroup avatars={pageAuthors} as="a" clickable limit={5} />
29-
),
24+
Authors: <AvatarGroup avatars={authors} as="a" limit={5} />,
3025
}
3126
: {}),
3227
Contribute: (

components/Navigation/index.jsx

Lines changed: 17 additions & 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,23 @@ export default () => {
1918
<NavBar
2019
Logo={Logo}
2120
sidebarItemTogglerAriaLabel="Toggle navigation menu"
22-
navItems={topNav}
21+
navItems={[
22+
{ link: '/learn', text: 'Learn' },
23+
{ link: '/about', text: 'About' },
24+
{ link: '/download', text: 'Download' },
25+
{ link: '/blog', text: 'Blog' },
26+
{ link: 'https://nodejs.org/docs/latest/api/', text: 'Docs' },
27+
{
28+
link: 'https://github.com/nodejs/node/blob/main/CONTRIBUTING.md',
29+
text: 'Contribute',
30+
target: '_blank',
31+
},
32+
{
33+
link: 'https://training.linuxfoundation.org/openjs/',
34+
text: 'Courses',
35+
target: '_blank',
36+
},
37+
]}
2338
>
2439
<SearchBox />
2540
<ThemeToggle

components/Sidebar/index.jsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import SideBar from '@node-core/ui-components/Containers/Sidebar';
22

3-
import { sideNav } from '../config.json' with { type: 'json' };
4-
53
/**
64
* Redirect to a URL
75
* @param {string} url URL
@@ -10,14 +8,24 @@ const redirect = url => (window.location.href = url);
108

119
/**
1210
* Sidebar component for MDX documentation with page navigation
13-
* @param {{ pathname: string }} props
11+
* @param {import('../Layout').Props} props
1412
*/
15-
export default ({ pathname }) => (
16-
<SideBar
17-
pathname={pathname}
18-
groups={sideNav}
19-
onSelect={redirect}
20-
as={props => <a {...props} rel="prefetch" />}
21-
title="Navigation"
22-
/>
23-
);
13+
export default ({ metadata }) => {
14+
const items = pages.map(([heading, path]) => ({
15+
label: heading,
16+
link:
17+
metadata.path === path
18+
? `${metadata.basename}.html`
19+
: `${relative(path, metadata.path)}.html`,
20+
}));
21+
22+
return (
23+
<SideBar
24+
pathname={`${metadata.basename}.html`}
25+
groups={[{ groupName: 'Learn Articles', items }]}
26+
onSelect={redirect}
27+
as={props => <a {...props} rel="prefetch" />}
28+
title="Navigation"
29+
/>
30+
);
31+
};

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
};

0 commit comments

Comments
 (0)