@alauda/doom 0.5.3 → 0.5.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/lib/cli/index.js CHANGED
@@ -27,6 +27,7 @@ program
27
27
  })
28
28
  .option('-c, --config [config]', 'Specify the path to the config file')
29
29
  .option('-v <version>', 'Specify the version of the documentation')
30
+ .option('-p, --prefix <prefix>', 'Specify the prefix of the documentation base')
30
31
  .command('dev', { isDefault: true })
31
32
  .description('Start the development server')
32
33
  .argument('[root]', 'Root directory of the documentation')
@@ -36,9 +37,9 @@ program
36
37
  setNodeEnv('development');
37
38
  let devServer;
38
39
  let cliWatcher;
39
- const { config: configFile, v: version, ...server } = this.optsWithGlobals();
40
+ const { config: configFile, v: version, prefix, ...server } = this.optsWithGlobals();
40
41
  const startDevServer = async () => {
41
- const { config, filepath } = await loadConfig(root, configFile, version);
42
+ const { config, filepath } = await loadConfig(root, configFile, prefix, version);
42
43
  const docDirectory = config.root;
43
44
  try {
44
45
  devServer = await dev({
@@ -101,8 +102,8 @@ program
101
102
  .argument('[root]', 'Root directory of the documentation')
102
103
  .action(async function (root) {
103
104
  setNodeEnv('production');
104
- const { config: configFile, v: version } = this.optsWithGlobals();
105
- const { config } = await loadConfig(root, configFile, version);
105
+ const { config: configFile, prefix, v: version, } = this.optsWithGlobals();
106
+ const { config } = await loadConfig(root, configFile, prefix, version);
106
107
  const docDirectory = config.root;
107
108
  await build({
108
109
  config,
@@ -119,8 +120,8 @@ program
119
120
  .option('--host [host]', 'Host name')
120
121
  .action(async function (root) {
121
122
  setNodeEnv('production');
122
- const { config: configFile, v: version, ...server } = this.optsWithGlobals();
123
- const { config } = await loadConfig(root, configFile, version);
123
+ const { config: configFile, prefix, v: version, ...server } = this.optsWithGlobals();
124
+ const { config } = await loadConfig(root, configFile, prefix, version);
124
125
  await serve({
125
126
  config,
126
127
  ...server,
@@ -1,5 +1,5 @@
1
1
  import { type DoomConfig } from '../utils/index.js';
2
- export declare function loadConfig(root?: string, configFile?: string, version?: string): Promise<{
2
+ export declare function loadConfig(root?: string, configFile?: string, prefix?: string, version?: string): Promise<{
3
3
  config: DoomConfig;
4
4
  filepath?: string;
5
5
  }>;
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { nodeTypes } from '@mdx-js/mdx';
4
- import { addLeadingSlash, addTrailingSlash, removeLeadingSlash, removeTrailingSlash, } from '@rspress/core';
4
+ import { addLeadingSlash, addTrailingSlash, normalizeSlash, removeLeadingSlash, removeTrailingSlash, } from '@rspress/core';
5
5
  import { pluginPreview } from '@rspress/plugin-preview';
6
6
  import { logger } from '@rspress/shared/logger';
7
7
  import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
@@ -100,7 +100,7 @@ const getCommonConfig = async (config, version) => {
100
100
  const findConfig = (basePath) => {
101
101
  return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
102
102
  };
103
- export async function loadConfig(root, configFile, version) {
103
+ export async function loadConfig(root, configFile, prefix, version) {
104
104
  let configFilePath;
105
105
  if (configFile) {
106
106
  configFilePath = path.resolve(configFile);
@@ -156,6 +156,9 @@ export async function loadConfig(root, configFile, version) {
156
156
  base = removeTrailingSlash(base) + `/${normalizedVersion}`;
157
157
  }
158
158
  mergedConfig.base = base = addTrailingSlash(base);
159
+ if (prefix) {
160
+ mergedConfig.base = normalizeSlash(prefix) + base;
161
+ }
159
162
  mergedConfig.root = resolveDocRoot(CWD, root, mergedConfig.root);
160
163
  let ensureDefaultLogo = false;
161
164
  if (!mergedConfig.logo) {
@@ -190,7 +193,7 @@ export async function loadConfig(root, configFile, version) {
190
193
  mergedConfig.outDir = `dist${normalizedVersion === 'unversioned' ? `/unversioned${base}` : base}`;
191
194
  }
192
195
  if (mergedConfig.builderConfig?.server?.open === true) {
193
- mergedConfig.builderConfig.server.open = base;
196
+ mergedConfig.builderConfig.server.open = mergedConfig.base;
194
197
  }
195
198
  return {
196
199
  config: mergedConfig,
@@ -33,7 +33,7 @@ export async function extractInfoFromFrontmatter(filePath, rootDir, extensions)
33
33
  const fileNameWithoutExt = path.basename(realPath, path.extname(realPath));
34
34
  const h1RegExp = /^#\s+(.*)$/m;
35
35
  const match = content.match(h1RegExp);
36
- let contentTitle = match?.[1];
36
+ let contentTitle = match?.[1]?.trim();
37
37
  if (contentTitle) {
38
38
  contentTitle =
39
39
  contentTitle.match(/{\s*useI18n\s*\(\s*\)\s*\(\s*(['"])([^'"]+)\1\s*\)\s*}/m)?.[2] ?? contentTitle;
@@ -122,7 +122,7 @@ export function Overview(props) {
122
122
  }
123
123
  return [];
124
124
  }, [overviewSidebarGroups, routePath, frontmatter]);
125
- return (_jsxs("div", { className: "overview-index mx-auto", children: [content, groups.map((group) => (_jsxs(Fragment, { children: [(group.name === title || group.name === defaultGroupTitle) &&
125
+ return (_jsxs("div", { className: "overview-index mx-auto", children: [content, groups.map((group) => (_jsxs(Fragment, { children: [(!title || [title, defaultGroupTitle].includes(group.name)) &&
126
126
  groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx("h2", { children: renderInlineMarkdown(group.name) })), _jsx("div", { className: classes.overviewGroups, children: group.items.map((item) => (_jsxs("div", { className: classes.overviewGroup, children: [_jsx("div", { className: "flex break-all", children: _jsx("h3", { style: { marginBottom: 8 }, children: _jsx(Link, { href: normalizeHref(item.link), children: renderInlineMarkdown(item.text) }) }) }), _jsx("div", { className: classes.overviewDescription, children: item.description }), _jsx("ul", { className: "list-none", children: item.headers?.map((header) => (_jsx("li", { className: `${classes.overviewGroupLi} ${classes[`level${header.depth}`]} first:mt-2`, children: _jsx(Link, { href: `${normalizeHref(item.link)}#${header.id}`, children: renderInlineMarkdown(header.text) }) }, header.id))) })] }, item.link))) })] }, group.name)))] }));
127
127
  }
128
128
  export default Overview;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -40,9 +40,9 @@
40
40
  "dependencies": {
41
41
  "@inquirer/prompts": "^7.2.1",
42
42
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
43
- "@rspress/core": "^1.38.0",
44
- "@rspress/plugin-preview": "^1.38.0",
45
- "@shikijs/transformers": "^1.24.3",
43
+ "@rspress/core": "^1.39.2",
44
+ "@rspress/plugin-preview": "^1.39.2",
45
+ "@shikijs/transformers": "^1.24.4",
46
46
  "chokidar": "^4.0.3",
47
47
  "clsx": "^2.1.1",
48
48
  "commander": "^12.1.0",
@@ -53,11 +53,11 @@
53
53
  "react-markdown": "^8.0.7",
54
54
  "rehype-raw": "^6.1.1",
55
55
  "remark-gfm": "^3.0.1",
56
- "shiki": "^1.24.3",
56
+ "shiki": "^1.24.4",
57
57
  "simple-git": "^3.27.0",
58
58
  "swagger2openapi": "^7.0.8",
59
59
  "tinyglobby": "^0.2.10",
60
- "type-fest": "^4.30.2",
60
+ "type-fest": "^4.31.0",
61
61
  "yaml": "^2.6.1",
62
62
  "yoctocolors": "^2.1.1"
63
63
  },
@@ -65,7 +65,7 @@
65
65
  "@eslint/js": "^9.17.0",
66
66
  "@swc-node/register": "^1.10.9",
67
67
  "@swc/core": "1.10.1",
68
- "@types/ejs": "^3",
68
+ "@types/ejs": "^3.1.5",
69
69
  "@types/eslint__js": "^8.42.3",
70
70
  "@types/fs-extra": "^11.0.4",
71
71
  "@types/node": "^18.19.68",
@@ -78,7 +78,7 @@
78
78
  "prettier-plugin-pkg": "^0.18.1",
79
79
  "simple-git-hooks": "^2.11.1",
80
80
  "typescript": "^5.7.2",
81
- "typescript-eslint": "^8.18.1"
81
+ "typescript-eslint": "^8.18.2"
82
82
  },
83
83
  "publishConfig": {
84
84
  "access": "public"