Skip to content

Commit f235a84

Browse files
committed
docs: add lib version
1 parent 783a453 commit f235a84

1 file changed

Lines changed: 25 additions & 16 deletions

File tree

docs/.vitepress/config.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1-
import { defineConfig } from 'vitepress'
2-
import { fileURLToPath } from 'url'
3-
import { resolve, dirname } from 'path'
4-
import react from '@vitejs/plugin-react'
5-
import { docsPlugin, buildSidebarFromDocs, ROOT } from '../../scripts/docs-plugin.js'
6-
7-
const __filename = fileURLToPath(import.meta.url)
8-
const __dirname = dirname(__filename)
1+
import { DefaultTheme, defineConfig } from 'vitepress';
2+
import { resolve } from 'path';
3+
import react from '@vitejs/plugin-react';
4+
import { docsPlugin, buildSidebarFromDocs, ROOT } from '../../scripts/docs-plugin.js';
5+
import packageJson from '../../package.json';
96

107
// Sidebar is built dynamically from the .md files generated by docsPlugin()
118
// At first run docs/ may be empty — the plugin fills it during buildStart
129
const sidebar = buildSidebarFromDocs()
1310

11+
const nav: DefaultTheme.NavItem[] = [
12+
{ text: 'Home', link: '/' },
13+
{ text: 'Hooks', link: '/hooks/state/createPubSubStore' },
14+
{ text: 'Components', link: '/components/ErrorBoundary' },
15+
{ text: 'Utils', link: '/utils/alphanumericCompare' },
16+
{ text: 'Types', link: '/types/' },
17+
{ text: 'npm', link: 'https://www.npmjs.com/package/@ndriadev/react-tools' }
18+
];
19+
20+
function buildNav(): DefaultTheme.NavItem[] {
21+
nav.push({
22+
text: packageJson.version,
23+
items: [
24+
{ text: 'Changelog', link: 'https://github.com/nDriaDev/react-tools/blob/main/CHANGELOG.md' }
25+
]
26+
});
27+
return nav;
28+
}
29+
1430
export default defineConfig({
1531
title: 'React Tools',
1632
description: 'A collection of Hooks, Components, Utilities and Types for React',
@@ -38,14 +54,7 @@ export default defineConfig({
3854
themeConfig: {
3955
logo: '/react-red.webp',
4056

41-
nav: [
42-
{ text: 'Home', link: '/' },
43-
{ text: 'Hooks', link: '/hooks/state/createPubSubStore' },
44-
{ text: 'Components', link: '/components/ErrorBoundary' },
45-
{ text: 'Utils', link: '/utils/alphanumericCompare' },
46-
{ text: 'Types', link: '/types/' },
47-
{ text: 'npm', link: 'https://www.npmjs.com/package/@ndriadev/react-tools' },
48-
],
57+
nav: buildNav(),
4958

5059
sidebar,
5160

0 commit comments

Comments
 (0)