11import { defineConfig } from 'vitepress'
2- import { name , description , ogUrl , ogImage } from './meta'
2+ import { name , description , ogUrl , ogImage , repository , mainBranch } from './meta'
33import { version } from '../../package.json'
4+ import { resolve } from 'node:path'
5+ import { fileURLToPath } from 'node:url'
6+ import { discoverUtilities } from './utilities'
7+ import { MarkdownTransform } from './plugins/markdownTransform'
8+ import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
9+ import tailwindcss from '@tailwindcss/vite'
10+
11+ const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) )
12+
13+ const utilities = await discoverUtilities ( )
414
515export default defineConfig ( {
6- title : 'feathers-hooks-common/index.js' ,
16+ title : name ,
717 lastUpdated : true ,
818 description : '' ,
919 head : [
@@ -19,24 +29,19 @@ export default defineConfig({
1929 [ 'meta' , { name : 'twitter:card' , content : 'summary_large_image' } ] ,
2030 ] ,
2131 themeConfig : {
22- siteTitle : 'feathers-hooks-common/index.js' ,
32+ siteTitle : name ,
2333 editLink : {
24- pattern :
25- 'https://github.com/feathersjs-ecosystem/feathers-hooks-common/edit/master/docs/:path' ,
34+ pattern : `https://github.com/${ repository } /edit/${ mainBranch } /docs/:path` ,
2635 } ,
2736 lastUpdatedText : 'Last Updated' ,
2837 socialLinks : [
29- {
30- icon : 'twitter' ,
31- link : 'https://twitter.com/feathersjs' ,
32- } ,
3338 {
3439 icon : 'discord' ,
3540 link : 'https://discord.gg/qa8kez8QBx' ,
3641 } ,
3742 {
3843 icon : 'github' ,
39- link : ' https://github.com/feathersjs-ecosystem/feathers-hooks-common/index.js' ,
44+ link : ` https://github.com/${ repository } ` ,
4045 } ,
4146 ] ,
4247 logo : '/feathers-hooks-common-logo.png' ,
@@ -45,8 +50,36 @@ export default defineConfig({
4550 text : 'Guide' ,
4651 items : [
4752 { text : 'Overview' , link : '/overview' } ,
48- { text : 'Hooks' , link : '/hooks/index.js' } ,
49- { text : 'Utilities' , link : '/utilities' } ,
53+ {
54+ text : 'Hooks' ,
55+ link : '/hooks' ,
56+ items : utilities
57+ . filter ( x => x . category === 'hooks' )
58+ . map ( x => ( {
59+ text : x . title ,
60+ link : x . path ,
61+ } ) ) ,
62+ } ,
63+ {
64+ text : 'Utilities' ,
65+ link : '/utils' ,
66+ items : utilities
67+ . filter ( x => x . category === 'utils' )
68+ . map ( x => ( {
69+ text : x . title ,
70+ link : x . path ,
71+ } ) ) ,
72+ } ,
73+ {
74+ text : 'Predicates' ,
75+ link : '/predicates' ,
76+ items : utilities
77+ . filter ( x => x . category === 'predicates' )
78+ . map ( x => ( {
79+ text : x . title ,
80+ link : x . path ,
81+ } ) ) ,
82+ } ,
5083 { text : 'Migrating' , link : '/migrating' } ,
5184 { text : 'Guides' , link : '/guides' } ,
5285 ] ,
@@ -58,11 +91,11 @@ export default defineConfig({
5891 items : [
5992 {
6093 text : 'Changelog' ,
61- link : ' https://github.com/feathersjs-ecosystem/feathers-hooks-common/ blob/master /CHANGELOG.md' ,
94+ link : ` https://github.com/${ repository } / blob/${ mainBranch } /CHANGELOG.md` ,
6295 } ,
6396 {
6497 text : 'Contributing' ,
65- link : ' https://github.com/feathersjs-ecosystem/feathers-hooks-common/ blob/master /.github/contributing.md' ,
98+ link : ` https://github.com/${ repository } / blob/${ mainBranch } /.github/contributing.md` ,
6699 } ,
67100 ] ,
68101 } ,
@@ -77,4 +110,36 @@ export default defineConfig({
77110 indexName : 'feathers-hooks' ,
78111 } ,
79112 } ,
113+ markdown : {
114+ codeTransformers : [
115+ transformerTwoslash ( {
116+ twoslashOptions : {
117+ compilerOptions : {
118+ paths : {
119+ 'feathers-commons' : [ resolve ( __dirname , '../../src/index.ts' ) ] ,
120+ 'feathers-commons/hooks' : [ resolve ( __dirname , '../../src/hooks/index.ts' ) ] ,
121+ 'feathers-commons/utils' : [ resolve ( __dirname , '../../src/utils/index.ts' ) ] ,
122+ 'feathers-commons/predicates' : [ resolve ( __dirname , '../../src/predicates/index.ts' ) ] ,
123+ 'feathers-commons/resolvers' : [ resolve ( __dirname , '../../src/resolvers/index.ts' ) ] ,
124+ } ,
125+ } ,
126+ } ,
127+ } ) ,
128+ ] ,
129+ // Explicitly load these languages for types hightlighting
130+ languages : [ 'js' , 'ts' ] ,
131+ } ,
132+ vite : {
133+ server : {
134+ fs : {
135+ allow : [ resolve ( __dirname , '../../src' ) ] ,
136+ } ,
137+ } ,
138+ plugins : [
139+ MarkdownTransform ( {
140+ vitepressDirectory : resolve ( __dirname , '../' ) ,
141+ } ) ,
142+ tailwindcss ( ) ,
143+ ] ,
144+ } ,
80145} )
0 commit comments