@alauda/doom 0.18.9 → 0.18.10
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/lib/cli/export.js +4 -1
- package/lib/cli/index.js +1 -0
- package/lib/cli/load-config.d.ts +1 -1
- package/lib/cli/load-config.js +4 -3
- package/lib/plugins/auto-sidebar/index.js +4 -3
- package/lib/shared/constants.d.ts +1 -0
- package/lib/shared/constants.js +1 -0
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/lib/cli/export.js
CHANGED
|
@@ -15,7 +15,10 @@ export const exportCommand = new Command('export')
|
|
|
15
15
|
.action(async function (root) {
|
|
16
16
|
setNodeEnv('production');
|
|
17
17
|
const { port, host, ...globalOptions } = this.optsWithGlobals();
|
|
18
|
-
let { config } = await loadConfig(root,
|
|
18
|
+
let { config } = await loadConfig(root, {
|
|
19
|
+
...globalOptions,
|
|
20
|
+
export: true,
|
|
21
|
+
});
|
|
19
22
|
const outDir = config.outDir;
|
|
20
23
|
if (!(await pathExists(path.resolve(outDir, 'index.html'), 'file'))) {
|
|
21
24
|
logger.error('Please build the documentation first');
|
package/lib/cli/index.js
CHANGED
|
@@ -36,6 +36,7 @@ program
|
|
|
36
36
|
2. translate ignore hash equality check and original text`, parseBoolean, false)
|
|
37
37
|
.option('-i, --ignore [boolean]', 'Ignore internal routes', parseBoolean, false)
|
|
38
38
|
.option('-d, --download [boolean]', 'Display download pdf link on nav bar', parseBoolean, false)
|
|
39
|
+
.option('-e, --export [boolean]', 'Run or build in exporting PDF mode, `apis/**` and `*/apis/**` routes will be ignored automatically', parseBoolean, false)
|
|
39
40
|
.option('--no-open [boolean]', 'Do not open the browser after starting the server')
|
|
40
41
|
.command('dev', { isDefault: true })
|
|
41
42
|
.description('Start the development server')
|
package/lib/cli/load-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UserConfig } from '@rspress/core';
|
|
2
2
|
import type { GlobalCliOptions } from '../types.js';
|
|
3
|
-
export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, ignore, force, open, lazy, }?: GlobalCliOptions): Promise<{
|
|
3
|
+
export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, }?: GlobalCliOptions): Promise<{
|
|
4
4
|
config: UserConfig;
|
|
5
5
|
filepath?: string;
|
|
6
6
|
}>;
|
package/lib/cli/load-config.js
CHANGED
|
@@ -19,7 +19,7 @@ const zhLocaleConfig = {
|
|
|
19
19
|
prevPageText: '上一页',
|
|
20
20
|
nextPageText: '下一页',
|
|
21
21
|
};
|
|
22
|
-
const getCommonConfig = ({ config, root, configFilePath, base, version, download, ignore, force, open, lazy, }) => {
|
|
22
|
+
const getCommonConfig = ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, }) => {
|
|
23
23
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
24
24
|
root = resolveDocRoot(CWD, root, config.root);
|
|
25
25
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
@@ -69,7 +69,7 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
69
69
|
apiPlugin({
|
|
70
70
|
localBasePath,
|
|
71
71
|
}),
|
|
72
|
-
autoSidebarPlugin({ ignore }),
|
|
72
|
+
autoSidebarPlugin({ export: export_, ignore }),
|
|
73
73
|
directivesPlugin(),
|
|
74
74
|
globalPlugin({ version, download }),
|
|
75
75
|
mermaidPlugin(),
|
|
@@ -134,7 +134,7 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
134
134
|
const findConfig = (basePath) => {
|
|
135
135
|
return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
|
|
136
136
|
};
|
|
137
|
-
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, ignore, force, open, lazy, } = {}) {
|
|
137
|
+
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, } = {}) {
|
|
138
138
|
let configFilePath;
|
|
139
139
|
if (configFile) {
|
|
140
140
|
configFilePath = path.resolve(configFile);
|
|
@@ -191,6 +191,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
191
191
|
base,
|
|
192
192
|
version,
|
|
193
193
|
download,
|
|
194
|
+
export: export_,
|
|
194
195
|
ignore,
|
|
195
196
|
force,
|
|
196
197
|
open,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { addTrailingSlash, } from '@rspress/core';
|
|
3
|
+
import { APIS_ROUTES } from '../../shared/index.js';
|
|
3
4
|
import { combineWalkResult } from './utils.js';
|
|
4
5
|
import { walk } from './walk.js';
|
|
5
6
|
// Scan all the directories and files in the work directory(such as `docs`), and then generate the nav and sidebar configuration according to the directory structure.
|
|
@@ -154,16 +155,16 @@ function processLocales(langs, versions, root, defaultLang, defaultVersion, exte
|
|
|
154
155
|
}));
|
|
155
156
|
}
|
|
156
157
|
const defaultExtensions = ['.mdx', '.md', '.tsx', '.jsx', '.ts', '.js'];
|
|
157
|
-
const APIS_ROUTES = ['apis/**', '*/apis/**'];
|
|
158
158
|
export const autoSidebar = async (config, { ignore, export: export_ }) => {
|
|
159
159
|
const excludeRoutes = (ignore && config.internalRoutes) || [];
|
|
160
160
|
const route = (config.route ??= {});
|
|
161
161
|
if (export_ || excludeRoutes.length) {
|
|
162
|
+
const exclude = (route.exclude ??= []);
|
|
163
|
+
exclude.push(...excludeRoutes);
|
|
164
|
+
// only exclude apis routes for sidebar but not site data to avoid dead links
|
|
162
165
|
if (export_) {
|
|
163
166
|
excludeRoutes.push(...APIS_ROUTES);
|
|
164
167
|
}
|
|
165
|
-
const exclude = (route.exclude ??= []);
|
|
166
|
-
exclude.push(...excludeRoutes);
|
|
167
168
|
}
|
|
168
169
|
config.themeConfig ??= {};
|
|
169
170
|
config.themeConfig.locales ??= config.locales || [];
|
package/lib/shared/constants.js
CHANGED
package/lib/types.d.ts
CHANGED