docus 3.0.1-20250616-151653-2de5ffe → 3.0.1-20250616-165151-c642df9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/modules/default-configs.ts +26 -0
- package/app/nuxt.config.ts +1 -0
- package/dist/main.mjs +25 -55
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineNuxtModule } from 'nuxt/kit'
|
|
2
|
+
import { defu } from 'defu'
|
|
3
|
+
import { inferSiteURL, getPackageJsonMetadata } from '../../cli/utils'
|
|
4
|
+
|
|
5
|
+
export default defineNuxtModule({
|
|
6
|
+
meta: {
|
|
7
|
+
name: 'default-configs',
|
|
8
|
+
},
|
|
9
|
+
async setup(_options, nuxt) {
|
|
10
|
+
const url = inferSiteURL()
|
|
11
|
+
const meta = await getPackageJsonMetadata(nuxt.options.rootDir)
|
|
12
|
+
|
|
13
|
+
// @ts-expect-error llms is not defined in the schema
|
|
14
|
+
nuxt.options.llms = defu(nuxt.options.llms, {
|
|
15
|
+
domain: url,
|
|
16
|
+
title: meta.name || '',
|
|
17
|
+
description: meta.description || '',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
nuxt.options.site = defu(nuxt.options.site, {
|
|
21
|
+
url,
|
|
22
|
+
name: meta.name || '',
|
|
23
|
+
debug: false,
|
|
24
|
+
})
|
|
25
|
+
},
|
|
26
|
+
})
|
package/app/nuxt.config.ts
CHANGED
package/dist/main.mjs
CHANGED
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
import * as dotenv from "dotenv";
|
|
5
5
|
|
|
6
6
|
// cli/cli.ts
|
|
7
|
-
import { resolve as
|
|
7
|
+
import { resolve as resolve3 } from "path";
|
|
8
8
|
import { defineCommand, runMain } from "citty";
|
|
9
9
|
|
|
10
10
|
// cli/setup.ts
|
|
11
11
|
import { fileURLToPath } from "url";
|
|
12
|
-
import { resolve } from "path";
|
|
13
|
-
import { readFile } from "fs/promises";
|
|
12
|
+
import { resolve as resolve2 } from "path";
|
|
14
13
|
|
|
15
14
|
// cli/git.ts
|
|
16
15
|
import { execSync } from "child_process";
|
|
@@ -85,31 +84,35 @@ function getGitEnv() {
|
|
|
85
84
|
};
|
|
86
85
|
}
|
|
87
86
|
|
|
87
|
+
// cli/utils.ts
|
|
88
|
+
import { readFile } from "fs/promises";
|
|
89
|
+
import { resolve } from "path";
|
|
90
|
+
async function getPackageJsonMetadata(dir) {
|
|
91
|
+
try {
|
|
92
|
+
const packageJson = await readFile(resolve(dir, "package.json"), "utf-8");
|
|
93
|
+
const parsed = JSON.parse(packageJson);
|
|
94
|
+
return {
|
|
95
|
+
name: parsed.name,
|
|
96
|
+
description: parsed.description
|
|
97
|
+
};
|
|
98
|
+
} catch {
|
|
99
|
+
return {
|
|
100
|
+
name: "docs"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
// cli/setup.ts
|
|
89
106
|
var appDir = fileURLToPath(new URL("../app", import.meta.url));
|
|
90
107
|
var pkgDir = fileURLToPath(new URL("..", import.meta.url));
|
|
91
108
|
async function getNuxtConfig(dir, _opts = {}) {
|
|
92
109
|
const meta = await getPackageJsonMetadata(dir);
|
|
93
|
-
|
|
94
|
-
const hasDocsDir = nuxt.options._layers.some((layer) => layer.cwd === dir);
|
|
95
|
-
if (!hasDocsDir) {
|
|
96
|
-
nuxt.options._layers.unshift({
|
|
97
|
-
cwd: dir,
|
|
98
|
-
config: {
|
|
99
|
-
rootDir: dir,
|
|
100
|
-
srcDir: dir
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
global.__DOCS_DIR__ = resolve(dir, "content");
|
|
110
|
+
global.__DOCS_DIR__ = resolve2(dir, "content");
|
|
106
111
|
const gitInfo = await getLocalGitInfo(dir) || getGitEnv();
|
|
107
|
-
const url = inferSiteURL();
|
|
108
112
|
return {
|
|
109
113
|
compatibilityDate: "2025-04-24",
|
|
110
114
|
extends: [appDir],
|
|
111
|
-
modulesDir: [
|
|
112
|
-
modules: ["nuxt-llms", fixLayers],
|
|
115
|
+
modulesDir: [resolve2(pkgDir, "node_modules"), resolve2(appDir, "node_modules")],
|
|
113
116
|
appConfig: {
|
|
114
117
|
header: {
|
|
115
118
|
title: meta.name || ""
|
|
@@ -126,42 +129,9 @@ async function getNuxtConfig(dir, _opts = {}) {
|
|
|
126
129
|
description: meta.description || ""
|
|
127
130
|
},
|
|
128
131
|
toc: {}
|
|
129
|
-
},
|
|
130
|
-
site: {
|
|
131
|
-
url,
|
|
132
|
-
name: meta.name || ""
|
|
133
|
-
},
|
|
134
|
-
llms: {
|
|
135
|
-
domain: url,
|
|
136
|
-
title: meta.name || "",
|
|
137
|
-
description: meta.description || "",
|
|
138
|
-
full: {
|
|
139
|
-
title: meta.name || "",
|
|
140
|
-
description: meta.description || ""
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
future: {
|
|
144
|
-
compatibilityVersion: 4
|
|
145
132
|
}
|
|
146
133
|
};
|
|
147
134
|
}
|
|
148
|
-
function inferSiteURL() {
|
|
149
|
-
return process.env.NUXT_SITE_URL || process.env.NEXT_PUBLIC_VERCEL_URL && `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` || process.env.URL || process.env.CI_PAGES_URL || process.env.CF_PAGES_URL;
|
|
150
|
-
}
|
|
151
|
-
async function getPackageJsonMetadata(dir) {
|
|
152
|
-
try {
|
|
153
|
-
const packageJson = await readFile(resolve(dir, "package.json"), "utf-8");
|
|
154
|
-
const parsed = JSON.parse(packageJson);
|
|
155
|
-
return {
|
|
156
|
-
name: parsed.name,
|
|
157
|
-
description: parsed.description
|
|
158
|
-
};
|
|
159
|
-
} catch {
|
|
160
|
-
return {
|
|
161
|
-
name: "docs"
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
135
|
|
|
166
136
|
// cli/cli.ts
|
|
167
137
|
function createCLI(opts) {
|
|
@@ -180,7 +150,7 @@ function createCLI(opts) {
|
|
|
180
150
|
},
|
|
181
151
|
args: { ...sharedArgs },
|
|
182
152
|
async setup({ args }) {
|
|
183
|
-
const dir =
|
|
153
|
+
const dir = resolve3(args.dir);
|
|
184
154
|
const { runCommand } = await import("nuxi");
|
|
185
155
|
await runCommand("init", [dir, "-t", "gh:nuxtlabs/docus/.starter", dir]);
|
|
186
156
|
}
|
|
@@ -192,7 +162,7 @@ function createCLI(opts) {
|
|
|
192
162
|
},
|
|
193
163
|
args: { ...sharedArgs },
|
|
194
164
|
async setup({ args }) {
|
|
195
|
-
const dir =
|
|
165
|
+
const dir = resolve3(args.dir);
|
|
196
166
|
const nuxtConfig = await getNuxtConfig(dir, {
|
|
197
167
|
...opts.setup,
|
|
198
168
|
dev: true
|
|
@@ -208,7 +178,7 @@ function createCLI(opts) {
|
|
|
208
178
|
},
|
|
209
179
|
args: { ...sharedArgs },
|
|
210
180
|
async setup({ args }) {
|
|
211
|
-
const dir =
|
|
181
|
+
const dir = resolve3(args.dir);
|
|
212
182
|
const nuxtConfig = await getNuxtConfig(dir, opts.setup);
|
|
213
183
|
const { runCommand } = await import("nuxi");
|
|
214
184
|
await runCommand("build", [dir], { overrides: nuxtConfig });
|