Skip to content

Commit c67473b

Browse files
committed
docs: use vitepress
1 parent 0a583d3 commit c67473b

Some content is hidden

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

44 files changed

+1650
-1939
lines changed

.github/CONTRIBUTING.md

+12
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ yarn test
7878

7979
(Partly outdated)
8080

81+
## Documentation update
82+
83+
Documentation uses `vitepress`.
84+
To run and edit teh documentation locally run:
85+
86+
```sh
87+
yarn install
88+
yarn build-dev
89+
```
90+
91+
For more information refer to [vitepress documentation](https://vitepress.dev).
92+
8193
## Publishing a release
8294

8395
```sh

.github/workflows/docs-deploy.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy docs site to Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: false
17+
18+
jobs:
19+
# Build job
20+
build:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 18
32+
cache: yarn
33+
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v4
36+
37+
- name: Install dependencies
38+
run: yarn install
39+
40+
- name: Build with VitePress
41+
run: |
42+
yarn docs-build
43+
touch ./docs/.vitepress/dist/.nojekyll
44+
45+
- name: Upload artifact
46+
uses: actions/upload-pages-artifact@v3
47+
with:
48+
path: ./docs/.vitepress/dist
49+
50+
# Deployment job
51+
deploy:
52+
environment:
53+
name: docs
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
needs: build
56+
runs-on: ubuntu-latest
57+
name: Deploy
58+
steps:
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v4

.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/cli/src/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ async function main(args: MainArgs): Promise<void> {
306306
name: 'empty-rules',
307307
message: [
308308
'Please add rules to your `commitlint.config.js`',
309-
' - Getting started guide: https://commitlint.js.org/#/?id=getting-started',
309+
' - Getting started guide: https://commitlint.js.org/guides/getting-started',
310310
' - Example config: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/src/index.ts',
311311
].join('\n'),
312312
},

@commitlint/cz-commitlint/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ yarn commit
5858

5959
## Related
6060

61-
- [Commitlint Reference Prompt](https://commitlint.js.org/#/reference-prompt) - How to customize prompt information by setting commitlint.config.js
61+
- [Commitlint Reference Prompt](https://commitlint.js.org/reference/prompt) - How to customize prompt information by setting commitlint.config.js

@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 = globSync(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 = globSync(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

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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: 'Plugins', link: '/plugins'},
41+
{text: 'Prompt', link: '/prompt'},
42+
{text: 'Examples', link: '/examples'},
43+
{text: 'Community projects', link: '/community-projects'},
44+
],
45+
},
46+
{
47+
text: 'API',
48+
base: '/api',
49+
collapsed: true,
50+
items: [
51+
{text: '@commitlint/format', link: '/format'},
52+
{text: '@commitlint/lint', link: '/lint'},
53+
{text: '@commitlint/load', link: '/load'},
54+
{text: '@commitlint/read', link: '/read'},
55+
],
56+
},
57+
{
58+
text: 'Concepts',
59+
base: '/concepts',
60+
collapsed: true,
61+
items: [
62+
{text: 'Commit-conventions', link: '/commit-conventions'},
63+
{text: 'Shareable config', link: '/shareable-config'},
64+
],
65+
},
66+
{
67+
text: 'Support',
68+
base: '/support',
69+
collapsed: true,
70+
items: [
71+
{text: 'Releases', link: '/releases'},
72+
{text: 'Upgrade commitlint', link: '/upgrade'},
73+
],
74+
},
75+
{
76+
text: 'Attributions',
77+
link: '/attributions',
78+
},
79+
],
80+
81+
socialLinks: [
82+
{
83+
icon: 'github',
84+
link: 'https://github.com/conventional-changelog/commitlint',
85+
},
86+
],
87+
88+
search: {
89+
provider: 'local',
90+
},
91+
},
92+
93+
markdown: {
94+
config(md) {
95+
md.use(tabsMarkdownPlugin);
96+
},
97+
},
98+
});

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.

0 commit comments

Comments
 (0)