@alauda/doom 0.0.0-alpha.1 → 0.0.0-alpha.11

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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="176" height="176" fill="none" fill-rule="evenodd" xmlns:v="https://vecta.io/nano"><path fill="#d8d8d8" opacity="0" d="M-8-12h200v200H-8z"/><g fill-rule="nonzero"><path d="M87.833 21.333c26.676 0 49.476 19.026 54.897 45.198l-5.879-2.798c-.977-.489-2.074-.733-3.173-.733a7.12 7.12 0 0 0-3.173.733L99.635 78.498c-2.014.976-3.477 2.746-3.966 4.941l-7.627 33.128c-.549 2.197 0 4.454 1.403 6.222l21.355 26.542c.609.768 1.345 1.386 2.162 1.84H40.539c-20.62-.063-37.871-15.908-39.99-36.729s11.578-39.912 31.75-44.252c3.967-28.039 27.63-48.857 55.534-48.857z" fill="#4da2f8"/><path d="M84.293 95.674l2.909 2.62 2.957 2.747 1.197 1.135-3.313 14.392c-.549 2.197 0 4.454 1.403 6.222l21.355 26.542c.609.768 1.345 1.386 2.162 1.84H40.539c-20.62-.063-37.871-15.908-39.99-36.729s11.578-39.912 31.75-44.252C45.8 68.435 63.132 76.93 84.293 95.674z" fill="#b3d7fc"/><path d="M175.166 115.81l-6.933-30.118c-.444-1.996-1.775-3.604-3.605-4.492l-28.065-13.367a6.47 6.47 0 0 0-2.884-.666 6.47 6.47 0 0 0-2.884.666l-28.065 13.423c-1.831.887-3.161 2.496-3.605 4.492l-6.933 30.117c-.499 1.997 0 4.049 1.275 5.657l19.413 24.129a6.54 6.54 0 0 0 5.158 2.495l31.28-.054c1.997 0 3.883-.943 5.158-2.496l19.415-24.127c1.275-1.608 1.719-3.661 1.275-5.657h0z" fill="#007af5"/><path d="M161.577 116.865c-.166 0-.278 0-.444-.057-.056-.054-.11-.054-.166-.054-.11 0-.222-.056-.332-.056-.388-.11-.666-.222-.999-.388-.166-.056-.332-.166-.499-.222h-.056c-1.055-.387-1.996-.721-2.884-.831h-.11c-.334 0-.5.166-.722.277-.054 0-.054.056-.11.056l-.666-.112a21.5 21.5 0 0 1-2.328 4.992c-1.887 2.996-4.382 5.436-7.322 7.156l.277.665c0 .056-.054.056-.054.11-.056.278-.166.502-.056.888.278.831.832 1.664 1.441 2.608v.054c.112.166.222.278.334.443.222.278.443.556.61.888.054.056.11.166.166.278 0 .056.054.056.054.11.222.444.222.943.11 1.387s-.443.777-.831.999a1.48 1.48 0 0 1-.665.166c-.666 0-1.331-.388-1.665-1.055 0 0-.054-.054-.054-.11-.056-.11-.112-.166-.166-.278-.168-.332-.222-.665-.334-.997l-.166-.5v-.054c-.388-1.055-.721-1.997-1.165-2.774-.222-.332-.443-.444-.721-.499-.056-.056-.056-.056-.11-.056l-.334-.609a24.66 24.66 0 0 1-2.884.831c-1.552.388-3.217.555-4.824.555a21.67 21.67 0 0 1-7.766-1.443l-.388.722c-.054.054-.054.054-.11.054-.222.112-.499.168-.721.5-.5.777-.778 1.663-1.165 2.773l-.166.5c-.112.332-.166.61-.334.997-.068.085-.123.178-.166.278 0 0-.054.056-.054.11-.332.61-.999 1.055-1.665 1.055-.221 0-.443-.056-.665-.166-.832-.388-1.165-1.443-.721-2.386 0 0 .054-.054.054-.11.056-.112.112-.222.166-.277.223-.334.388-.612.61-.888.112-.166.222-.278.332-.444v-.054c.612-.944 1.11-1.775 1.443-2.606.11-.39 0-.666-.112-.888 0-.054-.054-.054-.054-.112l.332-.721a22.46 22.46 0 0 1-2.386-1.608c-3.397-2.683-5.925-6.311-7.264-10.428l-.777.112c-.056 0-.056-.056-.112-.056-.166-.112-.388-.276-.721-.276h-.11c-.888.11-1.831.443-2.884.831h-.056c-.166.056-.332.166-.499.222-.334.166-.612.276-.999.388-.112 0-.222.054-.332.054 0 .056-.056.056-.112.056-.166.056-.277.056-.444.056-.885 0-1.608-.499-1.774-1.275-.166-.888.443-1.831 1.441-2.053.056-.054.112-.054.166-.054.112 0 .222-.056.334-.056.388-.054.721-.112 1.053-.112.168-.054.388-.054.555-.054h.056c1.165-.112 2.164-.222 2.995-.5a1.29 1.29 0 0 0 .61-.609c0-.056.056-.056.056-.112l.721-.221c-.721-5.104.332-10.262 3.106-14.644.054-.166.166-.278.277-.444l-.555-.499v-.112c0-.277 0-.555-.276-.831-.666-.61-1.499-1.109-2.496-1.719-.168-.112-.334-.222-.5-.278-.332-.166-.61-.332-.943-.555-.11-.056-.166-.165-.277-.222-.056 0-.056-.054-.112-.054-.777-.666-.943-1.775-.387-2.496.277-.388.775-.61 1.275-.61a1.94 1.94 0 0 1 1.219.444c0 .054.054.054.112.11.11.11.221.166.276.222.278.277.5.499.722.777.165.11.277.277.387.388.777.831 1.497 1.553 2.219 2.052.146.104.32.162.499.166.112 0 .222-.054.332-.054h.112l.555.387a21.38 21.38 0 0 1 10.983-6.211c.997-.222 1.996-.332 2.995-.444l.054-.721.112-.11c.166-.168.387-.334.444-.722.11-.887-.056-1.886-.168-2.995v-.056c-.054-.222-.054-.388-.11-.555-.11-.332-.166-.666-.166-1.053v-.444c-.013-.475.167-.935.499-1.275.332-.334.777-.555 1.221-.555.943 0 1.719.831 1.719 1.83v.499l-.166 1.055c-.056.168-.112.388-.112.555v.056c-.11 1.109-.222 2.106-.166 2.995.056.388.278.555.444.721l.11.112.056.721a22.15 22.15 0 0 1 11.592 4.604c.777.665 1.553 1.331 2.274 2.108l.666-.444h.11c.112.056.222.056.334.056.179-.004.353-.062.499-.166.721-.5 1.441-1.166 2.219-1.997.165-.11.277-.277.387-.388a9.38 9.38 0 0 1 .722-.777c.11-.054.166-.165.276-.222l.112-.11c.388-.278.775-.444 1.219-.444.5 0 .999.223 1.275.61.556.721.388 1.831-.388 2.496 0 .056-.054.056-.11.11-.11.112-.222.168-.276.222-.334.222-.61.388-.944.555-.166.112-.332.168-.499.278-.999.61-1.83 1.109-2.496 1.719-.222.278-.277.555-.277.832v.11l-.556.5c1.45 2.223 2.502 4.681 3.108 7.264.609 2.608.719 5.27.387 7.82l.721.222c0 .056.056.056.056.112.112.222.222.443.61.61.888.277 1.83.387 2.995.497h.056c.222.057.388.057.555.057.332 0 .666.054 1.055.11.11 0 .221.056.332.056 0 .054.056.054.11.054h.056c.999.278 1.609 1.165 1.609 1.831-.222.721-.944 1.277-1.775 1.277h0z" fill="#fff"/><path d="M136.563 101.5c.468.59 1.304.733 1.942.332l7.264-5.158h.001a16.84 16.84 0 0 0-9.984-4.826l.499 9.041c.056.222.112.443.278.61h0zm-11.036 6.434c.499-.61.443-1.553-.168-2.052l-6.6-5.88c-1.997 3.273-2.828 7.1-2.496 10.872l8.597-2.496a1.1 1.1 0 0 0 .666-.444h0zm3.937-5.825c.832 0 1.441-.665 1.497-1.441l.499-8.875-1.774.334h-.001a16.92 16.92 0 0 0-8.265 4.548l7.378 5.269c.168.112.444.166.666.166h0zm1.718 8.931l2.44 1.165 2.44-1.165.555-2.608-1.664-2.106h-2.718l-1.664 2.106zm9.097 2.608c-.634.316-.959 1.035-.777 1.719l3.493 8.373c2.108-1.387 3.937-3.161 5.324-5.379h.001c.721-1.053 1.277-2.162 1.609-3.383l-8.875-1.497c-.277 0-.555.056-.777.166zm10.259-8.376a17.77 17.77 0 0 0-2.106-5.27l-6.711 6.047a1.32 1.32 0 0 0-.334.61c-.173.777.289 1.555 1.055 1.774l8.485 2.442a17.43 17.43 0 0 0-.387-5.602h-.001 0zm-24.457 8.264l-8.819 1.496v.001a17.48 17.48 0 0 0 6.932 8.707l3.384-8.153c.112-.278.112-.555.054-.887-.166-.721-.831-1.222-1.552-1.165h0zm8.096 3.772c-.61-.332-1.33-.112-1.774.388l-4.383 7.931c1.777.555 3.661.888 5.602.888 1.333 0 2.608-.166 3.883-.444l1.608-.444-4.27-7.709a2.33 2.33 0 0 0-.666-.61h0z" fill="#007af5"/></g></svg>
@@ -3,3 +3,5 @@ export declare const YAML_EXTENSIONS: readonly [".yaml", ".yml"];
3
3
  export declare const JS_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
4
4
  export declare const DEFAULT_EXTENSIONS: readonly [".yaml", ".yml", ".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
5
5
  export declare const DEFAULT_CONFIGS: ("doom.config.yaml" | "doom.config.yml" | "doom.config.js" | "doom.config.ts" | "doom.config.mjs" | "doom.config.mts" | "doom.config.cjs" | "doom.config.cts")[];
6
+ export declare const I18N_FILE = "i18n.json";
7
+ export declare const CWD: string;
@@ -13,3 +13,5 @@ export const DEFAULT_EXTENSIONS = [
13
13
  ...JS_EXTENSIONS,
14
14
  ];
15
15
  export const DEFAULT_CONFIGS = DEFAULT_EXTENSIONS.map((ext) => `${DEFAULT_CONFIG_NAME}${ext}`);
16
+ export const I18N_FILE = 'i18n.json';
17
+ export const CWD = process.cwd();
package/lib/cli/index.js CHANGED
@@ -3,17 +3,16 @@
3
3
  * Adopted from @see https://github.com/web-infra-dev/rspress/blob/main/packages/cli/src/index.ts
4
4
  */
5
5
  import path from 'node:path';
6
+ import { logger } from '@rsbuild/core';
6
7
  import { build, dev, serve } from '@rspress/core';
7
8
  import { watch } from 'chokidar';
8
9
  import { program } from 'commander';
9
10
  import { green } from 'yoctocolors';
10
11
  import module from 'node:module';
11
- import { DEFAULT_CONFIGS } from './constants.js';
12
- import { loadConfig, resolveDocRoot } from './load-config.js';
13
- const I18N_FILE = 'i18n.json';
12
+ import { CWD, DEFAULT_CONFIGS, I18N_FILE } from './constants.js';
13
+ import { loadConfig } from './load-config.js';
14
14
  const META_FILE = '_meta.json';
15
15
  const CONFIG_FILES = [...DEFAULT_CONFIGS, I18N_FILE];
16
- const cwd = process.cwd();
17
16
  const setNodeEnv = (env) => {
18
17
  process.env.NODE_ENV = env;
19
18
  };
@@ -34,40 +33,42 @@ program
34
33
  let devServer;
35
34
  let cliWatcher;
36
35
  const startDevServer = async () => {
37
- const { config, filepath } = await loadConfig(configFile);
38
- config.root = resolveDocRoot(cwd, root, config.root);
39
- config.i18nSourcePath = path.resolve(config.root, I18N_FILE);
36
+ const { config, filepath } = await loadConfig(root, configFile);
40
37
  const docDirectory = config.root;
41
38
  try {
42
39
  devServer = await dev({
43
40
  config,
44
- appDirectory: cwd,
41
+ appDirectory: CWD,
45
42
  docDirectory,
46
43
  extraBuilderConfig: {
47
44
  server,
48
45
  },
49
46
  });
50
47
  }
51
- catch {
48
+ catch (err) {
49
+ logger.error(err);
52
50
  devServer = undefined;
53
51
  }
54
- cliWatcher = watch(filepath ? [filepath, docDirectory] : [...CONFIG_FILES, docDirectory], {
52
+ cliWatcher = watch(filepath
53
+ ? [filepath, docDirectory, config.i18nSourcePath]
54
+ : [...CONFIG_FILES, docDirectory], {
55
55
  ignoreInitial: true,
56
56
  ignored: ['**/node_modules/**', '**/.git/**', '**/.DS_Store/**'],
57
- cwd,
57
+ cwd: CWD,
58
58
  });
59
59
  let isRestarting = false;
60
60
  cliWatcher.on('all', async (eventName, filepath) => {
61
61
  if (eventName === 'add' ||
62
62
  eventName === 'unlink' ||
63
63
  (eventName === 'change' &&
64
- (CONFIG_FILES.includes(path.basename(filepath)) ||
64
+ (filepath === config.i18nSourcePath ||
65
+ CONFIG_FILES.includes(path.basename(filepath)) ||
65
66
  path.basename(filepath) === META_FILE))) {
66
67
  if (isRestarting) {
67
68
  return;
68
69
  }
69
70
  isRestarting = true;
70
- console.log(`\n✨ ${eventName} ${green(path.relative(cwd, filepath))}, dev server will restart...\n`);
71
+ console.log(`\n✨ ${eventName} ${green(path.relative(CWD, filepath))}, dev server will restart...\n`);
71
72
  await devServer?.close();
72
73
  await cliWatcher.close();
73
74
  await startDevServer();
@@ -92,13 +93,11 @@ program
92
93
  .description('Build the documentation')
93
94
  .action(async (root, { config: configFile }) => {
94
95
  setNodeEnv('production');
95
- const { config } = await loadConfig(configFile);
96
- config.root = resolveDocRoot(cwd, root, config.root);
97
- config.i18nSourcePath = path.resolve(config.root, I18N_FILE);
96
+ const { config } = await loadConfig(root, configFile);
98
97
  const docDirectory = config.root;
99
98
  await build({
100
99
  config,
101
- appDirectory: cwd,
100
+ appDirectory: CWD,
102
101
  docDirectory,
103
102
  });
104
103
  })
@@ -110,9 +109,7 @@ program
110
109
  .option('--host [host]', 'Host name')
111
110
  .action(async (root, { config: configFile, ...server }) => {
112
111
  setNodeEnv('production');
113
- const { config } = await loadConfig(configFile);
114
- config.root = resolveDocRoot(cwd, root, config.root);
115
- config.i18nSourcePath = path.resolve(config.root, I18N_FILE);
112
+ const { config } = await loadConfig(root, configFile);
116
113
  await serve({
117
114
  config,
118
115
  ...server,
@@ -1,5 +1,5 @@
1
- import type { UserConfig } from '@rspress/core';
2
- export declare function loadConfig(configFile?: string): Promise<{
1
+ import { type UserConfig } from '@rspress/core';
2
+ export declare function loadConfig(root?: string, configFile?: string): Promise<{
3
3
  config: UserConfig;
4
4
  filepath?: string;
5
5
  }>;
@@ -1,17 +1,19 @@
1
1
  import { nodeTypes } from '@mdx-js/mdx';
2
+ import { addLeadingSlash, addTrailingSlash, removeLeadingSlash, } from '@rspress/core';
2
3
  import { logger } from '@rspress/shared/logger';
3
4
  import fs from 'node:fs';
4
5
  import path from 'node:path';
5
6
  import rehypeRaw from 'rehype-raw';
6
7
  import { parse } from 'yaml';
7
8
  import { autoSidebarPlugin, globalPlugin } from '../plugins/index.js';
8
- import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, YAML_EXTENSIONS, } from './constants.js';
9
+ import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, YAML_EXTENSIONS, } from './constants.js';
10
+ import { pkgResolve } from '../utils/helpers.js';
11
+ const DEFAULT_LOGO = '/logo.svg';
9
12
  const COMMON_CONFIG = {
10
- base: '/docs',
11
13
  lang: 'en',
12
- logo: '/logo.svg',
13
- icon: '/logo.svg',
14
- outDir: 'dist',
14
+ route: {
15
+ exclude: ['shared/**/*', 'components/**/*', 'doom.config.*'],
16
+ },
15
17
  markdown: {
16
18
  checkDeadLinks: true,
17
19
  mdxRs: false,
@@ -38,50 +40,99 @@ const COMMON_CONFIG = {
38
40
  },
39
41
  plugins: [autoSidebarPlugin(), globalPlugin()],
40
42
  builderConfig: {
41
- dev: {
42
- lazyCompilation: true,
43
- },
44
43
  server: {
45
- open: '/docs/',
44
+ open: true,
45
+ },
46
+ tools: {
47
+ rspack: {
48
+ resolve: {
49
+ extensionAlias: {
50
+ '.js': ['.ts', '.tsx', '.js'],
51
+ },
52
+ },
53
+ },
46
54
  },
47
55
  },
48
56
  };
49
57
  const findConfig = (basePath) => {
50
58
  return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
51
59
  };
52
- export async function loadConfig(configFile) {
60
+ export async function loadConfig(root, configFile) {
53
61
  let configFilePath;
54
62
  if (configFile) {
55
63
  configFilePath = path.resolve(configFile);
56
64
  }
57
65
  else {
58
- configFilePath = findConfig(path.resolve(DEFAULT_CONFIG_NAME));
66
+ if (root) {
67
+ configFilePath = findConfig(path.resolve(root, DEFAULT_CONFIG_NAME));
68
+ }
69
+ if (!configFilePath) {
70
+ configFilePath = findConfig(path.resolve(DEFAULT_CONFIG_NAME));
71
+ }
72
+ // when root is not specified, try to find config in docs folder
73
+ if (!root && !configFilePath) {
74
+ configFilePath = findConfig(path.resolve('docs', DEFAULT_CONFIG_NAME));
75
+ }
59
76
  }
77
+ let config;
78
+ const { loadConfig, mergeRsbuildConfig } = await import('@rsbuild/core');
60
79
  if (!configFilePath) {
61
80
  logger.info(`No doom config file found in ${process.cwd()}`);
62
- return {
63
- config: {},
64
- };
65
81
  }
66
- const { loadConfig, mergeRsbuildConfig } = await import('@rsbuild/core');
67
- let config;
68
- try {
69
- if (YAML_EXTENSIONS.includes(path.extname(configFilePath))) {
70
- config = parse(fs.readFileSync(configFilePath, 'utf-8'));
82
+ else {
83
+ try {
84
+ if (YAML_EXTENSIONS.includes(path.extname(configFilePath))) {
85
+ config = parse(fs.readFileSync(configFilePath, 'utf-8'));
86
+ }
87
+ else {
88
+ const { content } = await loadConfig({
89
+ cwd: path.dirname(configFilePath),
90
+ path: configFilePath,
91
+ });
92
+ config = content;
93
+ }
94
+ }
95
+ catch {
96
+ logger.error(`Failed to load config from ${configFilePath}`);
97
+ }
98
+ }
99
+ const mergedConfig = mergeRsbuildConfig(COMMON_CONFIG, config ?? {});
100
+ const base = addLeadingSlash(mergedConfig.base || '/');
101
+ mergedConfig.base = base;
102
+ mergedConfig.root = resolveDocRoot(CWD, root, mergedConfig.root);
103
+ let ensureDefaultLogo = false;
104
+ if (!mergedConfig.logo) {
105
+ mergedConfig.logo = DEFAULT_LOGO;
106
+ ensureDefaultLogo = true;
107
+ }
108
+ if (!mergedConfig.icon) {
109
+ mergedConfig.icon = DEFAULT_LOGO;
110
+ ensureDefaultLogo = true;
111
+ }
112
+ if (ensureDefaultLogo) {
113
+ const publicPath = path.resolve(mergedConfig.root, `public`);
114
+ fs.mkdirSync(publicPath, { recursive: true });
115
+ const logoPath = path.resolve(publicPath, removeLeadingSlash(DEFAULT_LOGO));
116
+ if (!fs.existsSync(logoPath)) {
117
+ fs.copyFileSync(pkgResolve(`assets${DEFAULT_LOGO}`), logoPath);
71
118
  }
72
- else {
73
- const { content } = await loadConfig({
74
- cwd: path.dirname(configFilePath),
75
- path: configFilePath,
76
- });
77
- config = content;
119
+ }
120
+ if (mergedConfig.i18nSourcePath) {
121
+ if (!path.isAbsolute(mergedConfig.i18nSourcePath)) {
122
+ mergedConfig.i18nSourcePath = path.resolve(configFilePath ?? mergedConfig.root, mergedConfig.i18nSourcePath);
78
123
  }
79
124
  }
80
- catch {
81
- logger.error(`Failed to load config from ${configFilePath}`);
125
+ else {
126
+ mergedConfig.i18nSourcePath = path.resolve(mergedConfig.root, I18N_FILE);
127
+ }
128
+ if (!mergedConfig.outDir) {
129
+ mergedConfig.outDir = `dist${base}`;
130
+ }
131
+ if (mergedConfig.builderConfig?.server?.open === true) {
132
+ mergedConfig.builderConfig.server.open = addTrailingSlash(base);
82
133
  }
83
134
  return {
84
- config: mergeRsbuildConfig(COMMON_CONFIG, config ?? {}),
135
+ config: mergedConfig,
85
136
  filepath: configFilePath,
86
137
  };
87
138
  }
@@ -1,8 +1,8 @@
1
1
  import { addTrailingSlash } from '@rspress/core';
2
2
  import { logger } from '@rspress/shared/logger';
3
3
  import path from 'node:path';
4
- import { combineWalkResult } from './utils';
5
- import { walk } from './walk';
4
+ import { combineWalkResult } from './utils.js';
5
+ import { walk } from './walk.js';
6
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.
7
7
  // We will do as follows:
8
8
  // 1. scan the directory structure, and extract all the `_meta.json` files.
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { NavItem } from '@rspress/shared';
2
- import { DoomSidebar } from './walk';
2
+ import { DoomSidebar } from './walk.js';
3
3
  export declare function detectFilePath(rawPath: string, extensions: string[]): Promise<string | undefined>;
4
4
  export declare function extractInfoFromFrontmatter(filePath: string, rootDir: string, extensions: string[]): Promise<{
5
5
  realPath: string | undefined;
@@ -2,7 +2,7 @@ import { isExternalUrl, removeTrailingSlash, slash, withBase, } from '@rspress/s
2
2
  import fs from '@rspress/shared/fs-extra';
3
3
  import { logger } from '@rspress/shared/logger';
4
4
  import path from 'node:path';
5
- import { detectFilePath, extractInfoFromFrontmatter } from './utils';
5
+ import { detectFilePath, extractInfoFromFrontmatter } from './utils.js';
6
6
  const sidebarSorter = (a, b) => {
7
7
  if ('weight' in a && 'weight' in b) {
8
8
  return a.weight - b.weight;
@@ -100,7 +100,7 @@ export async function scanSideMeta(workDir, rootDir, docsDir, routePrefix, exten
100
100
  _fileKey: path.relative(docsDir, path.join(workDir, metaItem)),
101
101
  };
102
102
  }
103
- const { type = 'file', name, label = '', collapsible, collapsed, link, tag, dashed, overviewHeaders, context, } = metaItem;
103
+ const { type = 'file', name, label = '', collapsible, collapsed = true, link, tag, dashed, overviewHeaders, context, } = metaItem;
104
104
  // when type is divider, name maybe undefined, and link is not used
105
105
  const pureLink = `${relativePath}/${name.replace(/\.mdx?$/, '')}`;
106
106
  if (type === 'file') {
@@ -190,8 +190,8 @@ export async function walk(workDir, routePrefix = '/', docsDir, extensions) {
190
190
  for (const subDir of subDirs) {
191
191
  const { index, others } = await scanSideMeta(path.join(workDir, subDir), workDir, docsDir, routePrefix, extensions);
192
192
  const sidebar = index
193
- ? { ...index, collapsed: true, items: others }
194
- : { text: subDir, collapsed: true, items: others };
193
+ ? { ...index, items: others }
194
+ : { text: subDir, items: others };
195
195
  if (!sidebar.items.length) {
196
196
  // @ts-expect-error -- FIXME: rspress should handle `undefined` items
197
197
  delete sidebar.items;
@@ -1,14 +1,18 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- const componentsDir = path.resolve(import.meta.dirname, '../../runtime/components');
3
+ import { baseResolve, pkgResolve } from '../../utils/index.js';
4
+ const componentsDir = baseResolve('runtime/components');
4
5
  export const globalPlugin = () => {
5
6
  return {
6
7
  name: 'doom-global',
7
- globalStyles: path.resolve(import.meta.dirname, '../../../styles/global.scss'),
8
+ globalStyles: pkgResolve('styles/global.scss'),
8
9
  markdown: {
9
10
  globalComponents: fs
10
11
  .readdirSync(componentsDir)
11
- .filter((file) => path.basename(file, path.extname(file)) !== 'index')
12
+ .filter((file) => {
13
+ const basename = path.basename(file, path.extname(file));
14
+ return !basename.endsWith('.d') && basename !== 'index';
15
+ })
12
16
  .map((file) => path.resolve(componentsDir, file)),
13
17
  },
14
18
  };
@@ -1,2 +1,2 @@
1
- export * from './auto-sidebar';
2
- export * from './global';
1
+ export * from './auto-sidebar/index.js';
2
+ export * from './global/index.js';
@@ -1,2 +1,2 @@
1
- export * from './auto-sidebar';
2
- export * from './global';
1
+ export * from './auto-sidebar/index.js';
2
+ export * from './global/index.js';
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment, useMemo } from 'react';
3
- import { usePageData, normalizeHrefInRuntime as normalizeHref, withBase, isEqualPath, } from '@rspress/runtime';
4
2
  import { Link, renderInlineMarkdown, useSidebarData } from '@rspress/core/theme';
3
+ import { isEqualPath, normalizeHrefInRuntime as normalizeHref, usePageData, withBase, } from '@rspress/runtime';
4
+ import { Fragment, useMemo } from 'react';
5
5
  import classes from '../../../styles/overview.module.scss';
6
6
  // The sidebar data include two types: sidebar item and sidebar group.
7
7
  // In overpage page, we select all the related sidebar groups and show the groups in the page.
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Link } from '@rspress/core/theme';
3
- import classes from '../../../styles/quick-nav.module.scss';
4
3
  import { normalizeImagePath } from '@rspress/core/runtime';
4
+ import classes from '../../../styles/quick-nav.module.scss';
5
5
  export const QuickNav = ({ items }) => {
6
6
  return (_jsx("ul", { className: classes.container, children: items.map((item, index) => (_jsxs("li", { className: classes.item, children: [_jsxs("div", { className: classes.title, title: item.title, children: [_jsx("img", { src: normalizeImagePath(item.icon), alt: item.title }), item.title] }), _jsx("hr", { className: classes.divider }), _jsx("ul", { className: classes.links, children: item.links.map((link, index) => (_jsx("li", { children: _jsx(Link, { href: link.href, title: link.title, children: link.title }) }, index))) })] }, index))) }));
7
7
  };
@@ -1,2 +1,2 @@
1
- export * from './Overview';
2
- export * from './QuickNav';
1
+ export * from './Overview.js';
2
+ export * from './QuickNav.js';
@@ -1,2 +1,2 @@
1
- export * from './Overview';
2
- export * from './QuickNav';
1
+ export * from './Overview.js';
2
+ export * from './QuickNav.js';
@@ -1 +1,2 @@
1
- export * from './components';
1
+ /// <reference path="../../global.d.ts" preserve="true" />
2
+ export * from './components/index.js';
@@ -1,3 +1,3 @@
1
1
  // eslint-disable-next-line @typescript-eslint/triple-slash-reference
2
- /// <reference path="../../global.d.ts" />
3
- export * from './components';
2
+ /// <reference path="../../global.d.ts" preserve="true" />
3
+ export * from './components/index.js';
@@ -0,0 +1,2 @@
1
+ export declare const BASE_DIR: string;
2
+ export declare const PKG_DIR: string;
@@ -0,0 +1,4 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ export const BASE_DIR = path.resolve(fileURLToPath(import.meta.url), '../..');
4
+ export const PKG_DIR = path.resolve(BASE_DIR, '..');
@@ -0,0 +1,2 @@
1
+ export declare const baseResolve: (...paths: string[]) => string;
2
+ export declare const pkgResolve: (...paths: string[]) => string;
@@ -0,0 +1,4 @@
1
+ import path from 'node:path';
2
+ import { BASE_DIR, PKG_DIR } from './constants.js';
3
+ export const baseResolve = (...paths) => path.resolve(BASE_DIR, ...paths);
4
+ export const pkgResolve = (...paths) => path.resolve(PKG_DIR, ...paths);
@@ -0,0 +1,2 @@
1
+ export * from './constants.js';
2
+ export * from './helpers.js';
@@ -0,0 +1,2 @@
1
+ export * from './constants.js';
2
+ export * from './helpers.js';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.0.0-alpha.1",
3
+ "version": "0.0.0-alpha.11",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "https://gitlab-ce.alauda.cn/idp/Doom",
7
7
  "packageManager": "yarn@4.5.0",
8
8
  "engines": {
9
- "node": ">=20.11.0"
9
+ "node": ">=18.12.0"
10
10
  },
11
11
  "bin": "./lib/cli/index.js",
12
12
  "exports": {
@@ -14,6 +14,7 @@
14
14
  "./runtime": "./lib/runtime/index.js"
15
15
  },
16
16
  "files": [
17
+ "assets",
17
18
  "global.d.ts",
18
19
  "lib",
19
20
  "styles",
@@ -28,10 +29,11 @@
28
29
  "lint:es": "eslint .",
29
30
  "lint:tsc": "tsc -b --noEmit",
30
31
  "prepare": "simple-git-hooks",
32
+ "prepublishOnly": "yarn build",
31
33
  "swc-node": "node --enable-source-maps --import @swc-node/register/esm-register"
32
34
  },
33
35
  "dependencies": {
34
- "@rspress/core": "^1.35.2",
36
+ "@rspress/core": "^1.36.0",
35
37
  "chokidar": "^4.0.1",
36
38
  "commander": "^12.1.0",
37
39
  "rehype-raw": "^6.1.1",
@@ -39,20 +41,20 @@
39
41
  "yoctocolors": "^2.1.1"
40
42
  },
41
43
  "devDependencies": {
42
- "@eslint/js": "^9.13.0",
44
+ "@eslint/js": "^9.14.0",
43
45
  "@swc-node/register": "^1.10.9",
44
- "@swc/core": "1.7.40",
46
+ "@swc/core": "1.9.2",
45
47
  "@types/eslint__js": "^8.42.3",
46
48
  "@types/fs-extra": "^11.0.4",
47
- "@types/node": "^22.8.4",
48
- "eslint": "^9.13.0",
49
+ "@types/node": "~18.13.0",
50
+ "eslint": "^9.14.0",
49
51
  "lint-staged": "^15.2.10",
50
52
  "npm-run-all2": "^7.0.1",
51
53
  "prettier": "^3.3.3",
52
54
  "prettier-plugin-pkg": "^0.18.1",
53
55
  "simple-git-hooks": "^2.11.1",
54
56
  "typescript": "^5.6.3",
55
- "typescript-eslint": "^8.12.2"
57
+ "typescript-eslint": "^8.14.0"
56
58
  },
57
59
  "publishConfig": {
58
60
  "access": "public"