@alauda/doom 0.19.3 → 0.19.5
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/global.d.ts +1 -0
- package/lib/cli/load-config.js +9 -5
- package/lib/cli/translate.js +7 -5
- package/package.json +2 -1
package/global.d.ts
CHANGED
package/lib/cli/load-config.js
CHANGED
|
@@ -8,7 +8,7 @@ import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNota
|
|
|
8
8
|
import rehypeRaw from 'rehype-raw';
|
|
9
9
|
import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, shikiPlugin, } from '../plugins/index.js';
|
|
10
10
|
import {} from '../shared/index.js';
|
|
11
|
-
import { pkgResolve, resolveStaticConfig } from '../utils/index.js';
|
|
11
|
+
import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
|
|
12
12
|
import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
|
|
13
13
|
const DEFAULT_LOGO = '/logo.svg';
|
|
14
14
|
const zhLocaleConfig = {
|
|
@@ -27,7 +27,7 @@ const ruLocaleConfig = {
|
|
|
27
27
|
prevPageText: 'Предыдущая страница',
|
|
28
28
|
nextPageText: 'Следующая страница',
|
|
29
29
|
};
|
|
30
|
-
const getCommonConfig = ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, }) => {
|
|
30
|
+
const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, }) => {
|
|
31
31
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
32
32
|
root = resolveDocRoot(CWD, root, config.root);
|
|
33
33
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
@@ -70,8 +70,12 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
70
70
|
locales: [
|
|
71
71
|
{ lang: 'en', label: 'English' },
|
|
72
72
|
{ lang: 'zh', label: '简体中文', ...zhLocaleConfig },
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
(await pathExists(path.resolve(root, 'ru'), 'directory')) && {
|
|
74
|
+
lang: 'ru',
|
|
75
|
+
label: 'Русский',
|
|
76
|
+
...ruLocaleConfig,
|
|
77
|
+
},
|
|
78
|
+
].filter(Boolean),
|
|
75
79
|
}),
|
|
76
80
|
},
|
|
77
81
|
plugins: [
|
|
@@ -193,7 +197,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
version ||= '';
|
|
196
|
-
const commonConfig = getCommonConfig({
|
|
200
|
+
const commonConfig = await getCommonConfig({
|
|
197
201
|
config,
|
|
198
202
|
configFilePath,
|
|
199
203
|
root,
|
package/lib/cli/translate.js
CHANGED
|
@@ -217,15 +217,17 @@ export const translateCommand = new Command('translate')
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
await limit(async () => {
|
|
220
|
-
const
|
|
221
|
-
|
|
220
|
+
const sourceRelativePath = path.relative(docsDir, sourceFilePath);
|
|
221
|
+
const targetRelativePath = path.relative(docsDir, targetFilePath);
|
|
222
|
+
logger.info(`Translating ${cyan(sourceRelativePath)} to ${cyan(targetRelativePath)}`);
|
|
222
223
|
const isMdx = sourceFilePath.endsWith('.mdx');
|
|
223
224
|
const processor = isMdx ? mdxProcessor : mdProcessor;
|
|
224
225
|
const ast = processor.parse(escapeMarkdownHeadingIds(sourceContent));
|
|
226
|
+
const targetBase = path.dirname(targetFilePath);
|
|
225
227
|
const normalizeImgSrcOptions = {
|
|
226
228
|
localPublicBase: path.resolve(docsDir, 'public'),
|
|
227
229
|
sourceBase: path.dirname(sourceFilePath),
|
|
228
|
-
targetBase
|
|
230
|
+
targetBase,
|
|
229
231
|
translating: { source, target, copy },
|
|
230
232
|
};
|
|
231
233
|
const normalizedSourceContent = processor.stringify({
|
|
@@ -248,9 +250,9 @@ export const translateCommand = new Command('translate')
|
|
|
248
250
|
newFrontmatter.title = sourceFrontmatter.i18n.title[target];
|
|
249
251
|
}
|
|
250
252
|
targetContent = matter.stringify(content.startsWith('\n') ? content : '\n' + content, newFrontmatter);
|
|
251
|
-
await fs.mkdir(
|
|
253
|
+
await fs.mkdir(targetBase, { recursive: true });
|
|
252
254
|
await fs.writeFile(targetFilePath, targetContent);
|
|
253
|
-
logger.info(`${cyan(
|
|
255
|
+
logger.info(`${cyan(sourceRelativePath)} translated to ${cyan(targetRelativePath)}`);
|
|
254
256
|
allSourceFilePaths.delete(sourceFilePath);
|
|
255
257
|
});
|
|
256
258
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"@eslint/js": "^9.24.0",
|
|
81
81
|
"@swc-node/register": "^1.10.10",
|
|
82
82
|
"@swc/core": "1.11.21",
|
|
83
|
+
"@total-typescript/ts-reset": "^0.6.1",
|
|
83
84
|
"@types/cli-progress": "^3.11.6",
|
|
84
85
|
"@types/ejs": "^3.1.5",
|
|
85
86
|
"@types/node": "^18.19.86",
|