-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.config.ts
47 lines (45 loc) · 1.25 KB
/
content.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
import { existsSync } from 'node:fs'
import { defineCollection, defineContentConfig } from '@nuxt/content'
import { asSeoCollection } from '@nuxtjs/seo/content'
import { relative, resolve } from 'pathe'
import { logger } from './logger'
function getSubModuleCollection() {
const localDirPaths = new Set([
resolve(__dirname, '..', 'unhead', 'docs'),
])
for (const localDirPath of localDirPaths) {
if (existsSync(localDirPath)) {
logger.info(`🔗 Docs source using local fs: ${relative(process.cwd(), localDirPath)}`)
return defineCollection(asSeoCollection({
type: 'page',
source: {
include: '**/*.md',
cwd: localDirPath,
prefix: '/docs',
},
}))
}
}
// use github source
logger.info(`🔗 Docs source using GitHub`)
return defineCollection(asSeoCollection({
type: 'page',
source: {
repository: `https://github.com/unjs/unhead`,
include: 'docs/**/*.md',
prefix: `/docs`,
},
}))
}
export default defineContentConfig({
collections: {
docsUnhead: getSubModuleCollection(),
snippets: defineCollection({
type: 'page', // partial
source: {
include: '**/*.md',
cwd: resolve('./snippets'),
},
}),
},
})