/
config.ts
200 lines (177 loc) · 5.71 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// @ts-expect-error missing type
import base from '@vue/theme/config'
import { currentVersion, versions } from '../../meta/versions'
import { addonCategoryNames, categoryNames, coreCategoryNames, metadata } from '../../packages/metadata/metadata'
import highlight from './plugins/highlight'
const themeConfig = async () => {
const config = await base()
config.markdown.highlight = await highlight()
return config
}
const Guide = [
{ text: 'Get Started', link: '/guide/' },
{ text: 'Best Practice', link: '/guide/best-practice' },
{ text: 'Configurations', link: '/guide/config' },
{ text: 'Components', link: '/guide/components' },
{ text: 'Contributing', link: '/contributing' },
{ text: 'Guidelines', link: '/guidelines' },
]
const CoreCategories = coreCategoryNames.map(c => ({
text: c,
activeMatch: '___', // never active
link: `/functions#category=${c}`,
}))
const AddonCategories = [
...addonCategoryNames
.map(c => ({
text: c.slice(1),
activeMatch: '___', // never active
link: `/functions#category=${encodeURIComponent(c)}`,
})),
]
const Links = [
{ text: 'Add-ons', link: '/add-ons' },
{ text: 'Ecosystem', link: '/ecosystem' },
{ text: 'Export Size', link: '/export-size' },
{ text: 'Recent Updated', link: '/recent-updated' },
]
const DefaultSideBar = [
{ text: 'Guide', items: Guide },
{ text: 'Core Functions', items: CoreCategories },
{ text: 'Add-ons', items: AddonCategories },
{ text: 'Links', items: Links },
]
const FunctionsSideBar = getFunctionsSideBar()
/**
* @type {import('vitepress').UserConfig}
*/
const config = {
extends: themeConfig,
title: 'VueUse',
description: 'Collection of essential Vue Composition Utilities',
lang: 'en-US',
themeConfig: {
logo: '/favicon.svg',
repo: 'vueuse/vueuse',
docsDir: 'packages',
editLinks: true,
editLinkText: 'Edit this page',
lastUpdated: 'Last Updated',
algolia: {
apiKey: 'a99ef8de1b2b27949975ce96642149c6',
indexName: 'vueuse',
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/vueuse/vueuse' },
{ icon: 'twitter', link: 'https://twitter.com/vueuse' },
],
nav: [
{
text: 'Guide',
items: [
{ text: 'Guide', items: Guide },
{ text: 'Links', items: Links },
],
},
{
text: 'Functions',
items: [
{
text: '',
items: [
{ text: 'All Functions', link: '/functions#' },
{ text: 'Recent Updated', link: '/functions#sort=updated' },
],
},
{ text: 'Core', items: CoreCategories },
{ text: 'Add-ons', items: AddonCategories },
],
},
{
text: 'Add-ons',
link: '/add-ons',
},
{
text: 'Playground',
link: 'https://play.vueuse.org',
},
{
text: currentVersion,
items: [
{
items: [
{ text: 'Release Notes', link: 'https://github.com/vueuse/vueuse/releases' },
],
},
{
text: 'Versions',
items: versions.map(i => i.version === currentVersion
? {
text: `${i.version} (Current)`,
activeMatch: '/', // always active
link: '/',
}
: {
text: i.version,
link: i.link,
},
),
},
],
},
],
sidebar: {
'/guide/': DefaultSideBar,
'/contributing': DefaultSideBar,
'/add-ons': DefaultSideBar,
'/ecosystem': DefaultSideBar,
'/guidelines': DefaultSideBar,
'/export-size': DefaultSideBar,
'/recent-updated': DefaultSideBar,
'/functions': FunctionsSideBar,
'/core/': FunctionsSideBar,
'/shared/': FunctionsSideBar,
'/router/': FunctionsSideBar,
'/electron/': FunctionsSideBar,
'/rxjs/': FunctionsSideBar,
'/integrations/': FunctionsSideBar,
'/firebase/': FunctionsSideBar,
},
},
head: [
['meta', { name: 'theme-color', content: '#ffffff' }],
['link', { rel: 'icon', href: '/favicon-32x32.png', type: 'image/png' }],
['link', { rel: 'icon', href: '/favicon.svg', type: 'image/svg+xml' }],
['meta', { name: 'author', content: 'Anthony Fu' }],
['meta', { property: 'og:title', content: 'VueUse' }],
['meta', { property: 'og:image', content: 'https://vueuse.org/og.png' }],
['meta', { property: 'og:description', content: 'Collection of essential Vue Composition Utilities' }],
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { name: 'twitter:creator', content: '@antfu7' }],
['meta', { name: 'twitter:image', content: 'https://vueuse.org/og.png' }],
['link', { rel: 'dns-prefetch', href: 'https://fonts.gstatic.com' }],
['link', { rel: 'preconnect', crossorigin: 'anonymous', href: 'https://fonts.gstatic.com' }],
['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap' }],
['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Fira+Code&display=swap' }],
],
}
function getFunctionsSideBar() {
const links = []
for (const name of categoryNames) {
if (name.startsWith('_'))
continue
const functions = metadata.functions.filter(i => i.category === name && !i.internal)
links.push({
text: name,
items: functions.map(i => ({
text: i.name,
link: i.external || `/${i.package}/${i.name}/`,
})),
link: name.startsWith('@')
? functions[0].external || `/${functions[0].package}/README`
: undefined,
})
}
return links
}
export default config