Skip to content

Commit badf56c

Browse files
committed
docs: use vitepress
1 parent 2e225f7 commit badf56c

35 files changed

+1031
-1396
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ package.json.lerna_backup
1313
tsconfig.tsbuildinfo
1414
coverage
1515

16+
docs/.vitepress/dist
17+
docs/.vitepress/cache
18+
1619
# For testing nested workspaces does not have the package's dependencies name in the scope
1720
!**/config-lerna-scopes/fixtures/nested-workspaces/**/node_modules

@commitlint/rules/src/index.test.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ import rules from './index.js';
99

1010
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
1111

12+
function _glob(pattern: string) {
13+
const files = glob.sync(pattern, {
14+
ignore: ['**/index.ts', '**/*.test.ts'],
15+
cwd: __dirname,
16+
});
17+
return files.map(relative).map(toExport);
18+
}
19+
20+
function relative(filePath: string) {
21+
return path.relative(__dirname, filePath);
22+
}
23+
24+
function toExport(fileName: string) {
25+
return path.basename(fileName, path.extname(fileName));
26+
}
27+
1228
test('exports all rules', () => {
1329
const expected = _glob('*.ts').sort();
1430
const actual = Object.keys(rules).sort();
@@ -22,29 +38,13 @@ test('rules export functions', () => {
2238

2339
test('all rules are present in documentation', () => {
2440
const file = fs.readFileSync(
25-
path.join(__dirname, '../../../docs/reference-rules.md'),
41+
path.join(__dirname, '../../../docs/reference/rules.md'),
2642
'utf-8'
2743
);
2844
const results = file
2945
.split(/(\n|\r)/)
30-
.filter((s) => s.startsWith('####') && !s.includes('`deprecated`'))
31-
.map((s) => s.replace('#### ', ''));
46+
.filter((s) => s.startsWith('##') && !s.includes('`deprecated`'))
47+
.map((s) => s.replace('## ', ''));
3248

3349
expect(Object.keys(rules)).toEqual(expect.arrayContaining(results));
3450
});
35-
36-
function _glob(pattern: string) {
37-
const files = glob.sync(pattern, {
38-
ignore: ['**/index.ts', '**/*.test.ts'],
39-
cwd: __dirname,
40-
});
41-
return files.map(relative).map(toExport);
42-
}
43-
44-
function relative(filePath: string) {
45-
return path.relative(__dirname, filePath);
46-
}
47-
48-
function toExport(fileName: string) {
49-
return path.basename(fileName, path.extname(fileName));
50-
}

docs/.vitepress/config.ts

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import {defineConfig} from 'vitepress';
2+
import {tabsMarkdownPlugin} from 'vitepress-plugin-tabs';
3+
4+
// https://vitepress.dev/reference/site-config
5+
export default defineConfig({
6+
title: 'commitlint',
7+
description: 'Lint commit messages',
8+
9+
head: [['link', {rel: 'icon', type: 'image/png', href: '/assets/icon.png'}]],
10+
11+
themeConfig: {
12+
// https://vitepress.dev/reference/default-theme-config
13+
logo: '/assets/icon.png',
14+
15+
nav: [
16+
{text: 'Home', link: '/'},
17+
{text: 'Guides', link: '/guides/getting-started'},
18+
{text: 'Reference', link: '/reference/configuration'},
19+
],
20+
21+
sidebar: [
22+
{
23+
text: 'Guides',
24+
base: '/guides',
25+
items: [
26+
{text: 'Getting started', link: '/getting-started'},
27+
{text: 'Local setup', link: '/local-setup'},
28+
{text: 'CI setup', link: '/ci-setup'},
29+
{text: 'Use prompt', link: '/use-prompt'},
30+
],
31+
},
32+
{
33+
text: 'Reference',
34+
base: '/reference',
35+
items: [
36+
{text: 'CLI', link: '/cli'},
37+
{text: 'Configuration', link: '/configuration'},
38+
{text: 'Rules configuration', link: '/rules-configuration'},
39+
{text: 'Rules', link: '/rules'},
40+
{text: 'API', link: '/api'},
41+
{text: 'Plugins', link: '/plugins'},
42+
{text: 'Prompt', link: '/prompt'},
43+
{text: 'Examples', link: '/examples'},
44+
{text: 'Community projects', link: '/community-projects'},
45+
],
46+
},
47+
{
48+
text: 'Concepts',
49+
base: '/concepts',
50+
items: [
51+
{text: 'Commit-conventions', link: '/commit-conventions'},
52+
{text: 'Shareable config', link: '/shareable-config'},
53+
],
54+
},
55+
{
56+
text: 'Support',
57+
base: '/support',
58+
collapsed: true,
59+
items: [
60+
{text: 'Releases', link: '/releases'},
61+
{text: 'Upgrade commitlint', link: '/upgrade'},
62+
],
63+
},
64+
{
65+
text: 'Attributions',
66+
link: '/attributions',
67+
},
68+
],
69+
70+
socialLinks: [
71+
{
72+
icon: 'github',
73+
link: 'https://github.com/conventional-changelog/commitlint',
74+
},
75+
],
76+
77+
search: {
78+
provider: 'local',
79+
},
80+
},
81+
82+
markdown: {
83+
config(md) {
84+
md.use(tabsMarkdownPlugin);
85+
},
86+
},
87+
});

docs/.vitepress/theme/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// .vitepress/theme/index.ts
2+
import type {Theme} from 'vitepress';
3+
import DefaultTheme from 'vitepress/theme';
4+
import {enhanceAppWithTabs} from 'vitepress-plugin-tabs/client';
5+
6+
export default {
7+
extends: DefaultTheme,
8+
enhanceApp({app}) {
9+
enhanceAppWithTabs(app);
10+
},
11+
} satisfies Theme;

docs/README.md

-70
This file was deleted.

docs/_navbar.md

-7
This file was deleted.

docs/_sidebar.md

-22
This file was deleted.

docs/attributions.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Attributions
2+
3+
`commitlint` is possible because of the hard work of the folks of the `conventional-changelog` project
4+
5+
---
6+
7+
Thanks [@markusoelhafen](https://github.com/markusoelhafen) for providing
8+
the `commitlint` icon
9+
10+
---
11+
12+
Homepage SVG Demo generated with [svg-term-cli](https://github.com/marionebl/svg-term-cli)

docs/concepts-commit-conventions.md renamed to docs/concepts/commit-conventions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ With this additional information tools can derive useful human-readable informat
1010

1111
The most common commit conventions follow this pattern:
1212

13-
```
13+
```text
1414
type(scope?): subject
1515
body?
1616
footer?

docs/concepts-shareable-config.md renamed to docs/concepts/shareable-config.md

+44-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,33 @@
33
Most commonly shareable configuration is delivered as npm package exporting
44
an object containing `.rules` as default. To use shared configuration you specify it as item in the `.extends` array:
55

6-
```js
7-
// commitlint.config.js
8-
module.exports = {
6+
::: code-group
7+
8+
```js [commitlint.config.js]
9+
/**
10+
* @type {import('@commitlint/types').UserConfig}
11+
*/
12+
export default {
913
extends: ['example'], // => commitlint-config-example
1014
};
1115
```
1216

13-
This causes `commitlint` to pick up `commitlint-config-example`. Make it available by installing it.
17+
```ts [commitlint.config.ts]
18+
import type {UserConfig} from '@commitlint/types';
19+
20+
const config: UserConfig = {
21+
extends: ['example'], // => commitlint-config-example
22+
};
23+
24+
export default config;
25+
```
26+
27+
:::
28+
29+
This causes `commitlint` to pick up `commitlint-config-example`.
30+
Make it available by installing it.
1431

15-
```bash
32+
```sh
1633
npm install --save-dev commitlint-config-example
1734
```
1835

@@ -24,15 +41,33 @@ This works recursively, enabling shareable configuration to extend on an indefin
2441

2542
You can also load local configuration by using a relative path to the file.
2643

27-
> This must always start with a `.` (dot).
44+
::: warning
45+
This must always start with a `.` (dot).
46+
:::
2847

29-
```js
30-
// commitlint.config.js
31-
module.exports = {
48+
::: code-group
49+
50+
```js [commitlint.config.js]
51+
/**
52+
* @type {import('@commitlint/types').UserConfig}
53+
*/
54+
export default {
3255
extends: ['./example'], // => ./example.js
3356
};
3457
```
3558

59+
```ts [commitlint.config.ts]
60+
import type {UserConfig} from '@commitlint/types';
61+
62+
const config: UserConfig = {
63+
extends: ['./example'], // => ./example.js
64+
};
65+
66+
export default config;
67+
```
68+
69+
:::
70+
3671
## Scoped packages
3772

3873
When using scoped packages you have two options.

docs/guides-publish-config.md

-1
This file was deleted.

0 commit comments

Comments
 (0)