Skip to content

Commit 74b07b5

Browse files
committed
feat(scripts): set up
1 parent bf004a6 commit 74b07b5

11 files changed

Lines changed: 11305 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Contributing to nodejs/learn
2+
3+
Thank you for your interest in contributing! This repository contains the
4+
Node.js learning guides published at [learn.nodejs.org](https://learn.nodejs.org).
5+
6+
## Content structure
7+
8+
All articles live under `pages/`, organized into topic sections:
9+
10+
| Directory | Topics covered |
11+
| --------------------- | ------------------------------------------------------- |
12+
| `getting-started/` | Introduction, V8 engine, dev vs production, WebAssembly |
13+
| `asynchronous-work/` | Event loop, callbacks, promises, streams |
14+
| `command-line/` | REPL, environment variables, CLI I/O |
15+
| `diagnostics/` | Debugging, profiling, memory, performance |
16+
| `file-system/` | File paths, stats, reading, writing, folders |
17+
| `http/` | HTTP transactions, fetch, WebSockets, proxies |
18+
| `package-management/` | npm, publishing packages, Node-API modules |
19+
| `security/` | Security best practices |
20+
| `testing/` | Test runner, mocking, code coverage |
21+
| `typescript/` | TypeScript with Node.js |
22+
23+
## Making changes
24+
25+
### Editing an existing article
26+
27+
1. Find the relevant `.md` file under `pages/`.
28+
2. Edit the content (standard GitHub-flavored Markdown).
29+
3. Open a pull request — no build step required to review prose changes.
30+
31+
### Adding a new article
32+
33+
1. Choose the most relevant section directory, or propose a new one in your PR.
34+
2. Create a new `.md` file with a descriptive kebab-case name.
35+
3. Include frontmatter at the top of the file if required by `doc-kit`.
36+
37+
### Adding a new section
38+
39+
Open an issue first to discuss the proposed section before adding files.
40+
Refer to the [Card Sort results](https://github.com/nodejs/nodejs.org/issues/8234)
41+
for prior user-research context on content organisation.
42+
43+
## Building locally
44+
45+
```bash
46+
npm install
47+
npm run build
48+
# Output is written to out/
49+
```
50+
51+
## Code of Conduct
52+
53+
This project follows the
54+
[Node.js Code of Conduct](https://github.com/nodejs/admin/blob/main/CODE_OF_CONDUCT.md).

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# nodejs/learn
2+
3+
Source content for the Node.js learning guides, published at
4+
[learn.nodejs.org](https://learn.nodejs.org).
5+
6+
This repository was created as part of
7+
[nodejs/nodejs.org#8612](https://github.com/nodejs/nodejs.org/issues/8612)
8+
to give the Learn content a dedicated home, separate from the main website
9+
monorepo. Content editors no longer need to deal with Next.js tooling or
10+
website-specific git hooks.
11+
12+
## Content
13+
14+
All articles are Markdown files under `pages/`, grouped by topic:
15+
16+
```
17+
pages/
18+
├── getting-started/ # Introduction to Node.js
19+
├── asynchronous-work/ # Event loop, callbacks, promises, streams
20+
├── command-line/ # REPL, environment variables, CLI I/O
21+
├── diagnostics/ # Debugging, profiling, memory, performance
22+
├── file-system/ # File paths, stats, reading/writing, folders
23+
├── http/ # HTTP, fetch, WebSockets, proxies
24+
├── package-management/ # npm, publishing packages, Node-API modules
25+
├── security/ # Security best practices
26+
├── testing/ # Test runner, mocking, code coverage
27+
└── typescript/ # TypeScript with Node.js
28+
```
29+
30+
The structure is based on
31+
[Card Sort research](https://github.com/nodejs/nodejs.org/issues/8234)
32+
conducted at the 2025 Cambridge Node.js Collaborators' Summit.
33+
34+
## Development
35+
36+
```bash
37+
npm install
38+
npm run build # generates static site + Orama search DB in out/
39+
```
40+
41+
## Contributing
42+
43+
See [CONTRIBUTING.md](CONTRIBUTING.md).

components/Metabar/index.jsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import MetaBar from '@node-core/ui-components/Containers/MetaBar';
2+
import AvatarGroup from '@node-core/ui-components/Common/AvatarGroup';
3+
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
4+
5+
import { authors } from '../config.json' with { type: 'json' };
6+
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];
18+
19+
return (
20+
<MetaBar
21+
heading="Table of Contents"
22+
headings={{ items: headings }}
23+
items={{
24+
'Reading Time': readingTime,
25+
...(CLIENT && pageAuthors?.length
26+
? {
27+
Authors: (
28+
<AvatarGroup avatars={pageAuthors} as="a" clickable limit={5} />
29+
),
30+
}
31+
: {}),
32+
Contribute: (
33+
<>
34+
<GitHubIcon className="fill-neutral-700 dark:fill-neutral-100" />
35+
<a href={editThisPage}>Edit this page</a>
36+
</>
37+
),
38+
}}
39+
/>
40+
);
41+
};

components/Navigation/index.jsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import ThemeToggle from '@node-core/ui-components/Common/ThemeToggle';
2+
import NavBar from '@node-core/ui-components/Containers/NavBar';
3+
import styles from '@node-core/ui-components/Containers/NavBar/index.module.css';
4+
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
5+
6+
import SearchBox from '@node-core/doc-kit/src/generators/web/ui/components/SearchBox';
7+
import { useTheme } from '@node-core/doc-kit/src/generators/web/ui/hooks/useTheme.mjs';
8+
9+
import Logo from '#theme/Logo';
10+
import { topNav } from '../config.json' with { type: 'json' };
11+
12+
/**
13+
* NavBar component that displays the headings, search, etc.
14+
*/
15+
export default () => {
16+
const [theme, toggleTheme] = useTheme();
17+
18+
return (
19+
<NavBar
20+
Logo={Logo}
21+
sidebarItemTogglerAriaLabel="Toggle navigation menu"
22+
navItems={topNav}
23+
>
24+
<SearchBox />
25+
<ThemeToggle
26+
onClick={toggleTheme}
27+
aria-label={`Switch to ${theme === 'light' ? 'dark' : 'light'} theme`}
28+
/>
29+
<a
30+
href={`https://github.com/nodejs/learn`}
31+
className={styles.ghIconWrapper}
32+
>
33+
<GitHubIcon />
34+
</a>
35+
</NavBar>
36+
);
37+
};

components/Sidebar/index.jsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import SideBar from '@node-core/ui-components/Containers/Sidebar';
2+
3+
import { sideNav } from '../config.json' with { type: 'json' };
4+
5+
/**
6+
* Redirect to a URL
7+
* @param {string} url URL
8+
*/
9+
const redirect = url => (window.location.href = url);
10+
11+
/**
12+
* Sidebar component for MDX documentation with page navigation
13+
* @param {{ pathname: string }} props
14+
*/
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+
);

doc-kit.config.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import web from '@node-core/doc-kit/src/generators/web/index.mjs';
2+
import { join } from 'node:path';
3+
4+
/** @type {import('@node-core/doc-kit/src/utils/configuration/types.d.ts').Configuration} */
5+
export default {
6+
global: {
7+
output: 'out',
8+
input: ['pages/**/*.md'],
9+
},
10+
'jsx-ast': {
11+
pageURL: 'https://learn.nodejs.org{path}.html',
12+
editURL: 'https://github.com/nodejs/learn/edit/main/pages{path}.md',
13+
},
14+
web: {
15+
title: '',
16+
imports: {
17+
...web.defaultConfiguration.imports,
18+
'#theme/Navigation': join(
19+
import.meta.dirname,
20+
'components/Navigation/index.jsx'
21+
),
22+
'#theme/Sidebar': join(
23+
import.meta.dirname,
24+
'components/Sidebar/index.jsx'
25+
),
26+
'#theme/Metabar': join(
27+
import.meta.dirname,
28+
'components/Metabar/index.jsx'
29+
),
30+
},
31+
},
32+
};

eslint.config.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import globals from 'globals';
4+
import { defineConfig } from 'eslint/config';
5+
import * as mdx from 'eslint-plugin-mdx';
6+
7+
export default defineConfig(
8+
{ ignores: ['out'] },
9+
eslint.configs.recommended,
10+
tseslint.configs.recommended,
11+
mdx.flatCodeBlocks,
12+
{
13+
languageOptions: {
14+
globals: globals.nodeBuiltin,
15+
},
16+
},
17+
{
18+
files: ['**/*.{md,mdx}/*.cjs'],
19+
rules: {
20+
'@typescript-eslint/no-require-imports': 'off',
21+
},
22+
},
23+
{
24+
...mdx.flat,
25+
processor: mdx.createRemarkProcessor({ lintCodeBlocks: true }),
26+
rules: {
27+
...mdx.flat.rules,
28+
'no-irregular-whitespace': 'off',
29+
},
30+
}
31+
);

0 commit comments

Comments
 (0)