-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
89 lines (61 loc) · 2.18 KB
/
index.ts
File metadata and controls
89 lines (61 loc) · 2.18 KB
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
import {defineNuxtModule, createResolver, addComponentsDir, extendPages, addImportsDir, installModule} from '@nuxt/kit'
import {registerTailwindPath} from "@owdproject/core/runtime/utils/utilsApp";
import { cpSync, existsSync, mkdirSync } from 'fs';
import { join } from 'path';
const {resolve} = createResolver(import.meta.url);
export default defineNuxtModule({
meta: {
name: 'owd-docs',
priority: -1
},
async setup(options, nuxt) {
{
// install tailwind
registerTailwindPath(nuxt, resolve('./runtime/components/**/*.{vue,mjs,ts}'))
}
{
// add css
nuxt.options.css.push(resolve('./runtime/assets/styles/docs.scss'))
}
{
// add runtime components
addComponentsDir({
path: resolve("./runtime/components"),
prefix: "",
global: true,
})
}
{
// add pages
extendPages((pages) => {
pages.push({
name: 'Docs',
path: '/docs',
file: resolve('./runtime/pages/docs/index.vue'),
})
pages.push({
name: 'Page',
path: '/docs/:slug',
file: resolve('./runtime/pages/docs/[slug].vue'),
})
})
}
{
// add content
const sourceContentDir = resolve('./runtime/content');
const targetContentDir = join(nuxt.options.rootDir, 'content');
nuxt.options.build.transpile.push('@nuxt/content');
await installModule('@nuxt/content');
await installModule('nuxt-toc');
try {
if (!existsSync(targetContentDir)) {
mkdirSync(targetContentDir, { recursive: true });
}
cpSync(sourceContentDir, targetContentDir, { recursive: true });
console.log('[OWD] Copied content to project root');
} catch (err) {
console.error('[OWD] Failed to copy content to root', err);
}
}
}
})