@alauda/doom 0.4.0 → 0.4.1

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.
Files changed (47) hide show
  1. package/lib/cli/constants.d.ts +1 -0
  2. package/lib/cli/constants.js +1 -0
  3. package/lib/cli/index.js +4 -3
  4. package/lib/cli/load-config.d.ts +1 -1
  5. package/lib/cli/load-config.js +12 -4
  6. package/lib/global/VersionsNav/Down.d.ts +1 -0
  7. package/lib/global/VersionsNav/Down.js +2 -0
  8. package/lib/global/VersionsNav/NavMenuGroup.d.ts +12 -0
  9. package/lib/global/VersionsNav/NavMenuGroup.js +53 -0
  10. package/lib/global/VersionsNav/NavMenuSingleItem.d.ts +10 -0
  11. package/lib/global/VersionsNav/NavMenuSingleItem.js +9 -0
  12. package/lib/global/VersionsNav/SvgWrapper.d.ts +7 -0
  13. package/lib/global/VersionsNav/SvgWrapper.js +14 -0
  14. package/lib/global/VersionsNav/index.d.ts +2 -0
  15. package/lib/global/VersionsNav/index.js +55 -0
  16. package/lib/plugins/api/index.js +3 -3
  17. package/lib/plugins/global/index.js +8 -0
  18. package/lib/runtime/components/Badge.d.ts +1 -1
  19. package/lib/runtime/components/Badge.js +1 -1
  20. package/lib/runtime/components/Card.d.ts +1 -1
  21. package/lib/runtime/components/Card.js +1 -1
  22. package/lib/runtime/components/ExternalSite.d.ts +9 -0
  23. package/lib/runtime/components/ExternalSite.js +28 -0
  24. package/lib/runtime/components/K8sCrd.js +1 -1
  25. package/lib/runtime/components/LinkCard.d.ts +1 -1
  26. package/lib/runtime/components/LinkCard.js +1 -1
  27. package/lib/runtime/components/OpenAPIRef.js +1 -1
  28. package/lib/runtime/components/PackageManagerTabs.d.ts +1 -1
  29. package/lib/runtime/components/PackageManagerTabs.js +1 -1
  30. package/lib/runtime/components/Steps.d.ts +1 -1
  31. package/lib/runtime/components/Steps.js +1 -1
  32. package/lib/runtime/components/Tab.d.ts +1 -1
  33. package/lib/runtime/components/Tab.js +1 -1
  34. package/lib/runtime/components/Tabs.d.ts +1 -1
  35. package/lib/runtime/components/Tabs.js +1 -1
  36. package/lib/runtime/components/Toc.d.ts +1 -1
  37. package/lib/runtime/components/Toc.js +1 -1
  38. package/lib/runtime/components/_Directive.d.ts +10 -0
  39. package/lib/runtime/components/_Directive.js +16 -0
  40. package/lib/runtime/components/index.d.ts +2 -1
  41. package/lib/runtime/components/index.js +2 -1
  42. package/lib/runtime/types.d.ts +2 -0
  43. package/lib/runtime/utils.d.ts +2 -0
  44. package/lib/runtime/utils.js +5 -0
  45. package/lib/utils/types.d.ts +8 -0
  46. package/package.json +2 -1
  47. package/styles/versions-nav.module.scss +11 -0
@@ -6,4 +6,5 @@ export declare const JS_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".mts", ".cj
6
6
  export declare const DEFAULT_EXTENSIONS: readonly [".yaml", ".yml", ".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
7
7
  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")[];
8
8
  export declare const I18N_FILE = "i18n.json";
9
+ export declare const SITES_FILE = "sites.yaml";
9
10
  export declare const CWD: string;
@@ -19,4 +19,5 @@ export const DEFAULT_EXTENSIONS = [
19
19
  ];
20
20
  export const DEFAULT_CONFIGS = DEFAULT_EXTENSIONS.map((ext) => `${DEFAULT_CONFIG_NAME}${ext}`);
21
21
  export const I18N_FILE = 'i18n.json';
22
+ export const SITES_FILE = 'sites.yaml';
22
23
  export const CWD = process.cwd();
package/lib/cli/index.js CHANGED
@@ -9,10 +9,10 @@ import { build, dev, serve } from '@rspress/core';
9
9
  import { watch } from 'chokidar';
10
10
  import { program } from 'commander';
11
11
  import { green } from 'yoctocolors';
12
- import { CWD, DEFAULT_CONFIGS, I18N_FILE } from './constants.js';
12
+ import { CWD, DEFAULT_CONFIGS, I18N_FILE, SITES_FILE } from './constants.js';
13
13
  import { loadConfig } from './load-config.js';
14
14
  const META_FILE = '_meta.json';
15
- const CONFIG_FILES = [...DEFAULT_CONFIGS, I18N_FILE];
15
+ const CONFIG_FILES = [...DEFAULT_CONFIGS, I18N_FILE, SITES_FILE];
16
16
  const setNodeEnv = (env) => {
17
17
  process.env.NODE_ENV = env;
18
18
  };
@@ -50,7 +50,7 @@ program
50
50
  devServer = undefined;
51
51
  }
52
52
  cliWatcher = watch(filepath
53
- ? [filepath, docDirectory, config.i18nSourcePath]
53
+ ? [filepath, config.i18nSourcePath, docDirectory, SITES_FILE]
54
54
  : [...CONFIG_FILES, docDirectory], {
55
55
  ignoreInitial: true,
56
56
  ignored: ['**/node_modules/**', '**/.git/**', '**/.DS_Store/**'],
@@ -58,6 +58,7 @@ program
58
58
  });
59
59
  let isRestarting = false;
60
60
  cliWatcher.on('all', async (eventName, filepath) => {
61
+ console.log(eventName, filepath);
61
62
  if (eventName === 'add' ||
62
63
  eventName === 'unlink' ||
63
64
  (eventName === 'change' &&
@@ -1,4 +1,4 @@
1
- import { DoomConfig } from '../utils/types.js';
1
+ import { type DoomConfig } from '../utils/index.js';
2
2
  export declare function loadConfig(root?: string, configFile?: string): Promise<{
3
3
  config: DoomConfig;
4
4
  filepath?: string;
@@ -7,10 +7,9 @@ import { logger } from '@rspress/shared/logger';
7
7
  import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
8
8
  import getPort from 'get-port';
9
9
  import rehypeRaw from 'rehype-raw';
10
- import { parse } from 'yaml';
11
10
  import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, globalPlugin, shikiPlugin, } from '../plugins/index.js';
12
- import { pkgResolve } from '../utils/helpers.js';
13
- import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, YAML_EXTENSIONS, } from './constants.js';
11
+ import { pkgResolve, resolveStaticConfig, } from '../utils/index.js';
12
+ import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
14
13
  const DEFAULT_LOGO = '/logo.svg';
15
14
  const zhLocaleConfig = {
16
15
  searchPlaceholderText: '搜索文档',
@@ -125,7 +124,7 @@ export async function loadConfig(root, configFile) {
125
124
  else {
126
125
  try {
127
126
  if (YAML_EXTENSIONS.includes(path.extname(configFilePath))) {
128
- config = parse(fs.readFileSync(configFilePath, 'utf-8'));
127
+ config = await resolveStaticConfig(configFilePath);
129
128
  }
130
129
  else {
131
130
  const { content } = await loadConfig({
@@ -140,6 +139,15 @@ export async function loadConfig(root, configFile) {
140
139
  }
141
140
  }
142
141
  config ??= {};
142
+ if (config.sites) {
143
+ logger.error('Use separate `sites.yaml` config in repository root instead');
144
+ }
145
+ else {
146
+ const sitesConfigFilePath = path.resolve(SITES_FILE);
147
+ if (fs.existsSync(sitesConfigFilePath)) {
148
+ config.sites = await resolveStaticConfig(sitesConfigFilePath);
149
+ }
150
+ }
143
151
  const mergedConfig = mergeRsbuildConfig(await getCommonConfig(config), config);
144
152
  const base = addLeadingSlash(mergedConfig.base || '/');
145
153
  mergedConfig.base = base;
@@ -0,0 +1 @@
1
+ export declare const SvgDown: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const SvgDown = () => (_jsx("svg", { width: "1em", height: "1em", viewBox: "0 0 32 32", children: _jsx("path", { fill: "currentColor", d: "M16 22L6 12l1.4-1.4l8.6 8.6l8.6-8.6L26 12z" }) }));
@@ -0,0 +1,12 @@
1
+ import { type NavItem } from '@rspress/shared';
2
+ export interface NavMenuGroupItem {
3
+ text?: string | React.ReactElement;
4
+ link?: string;
5
+ items: NavItem[];
6
+ tag?: string;
7
+ activeValue?: string;
8
+ pathname?: string;
9
+ base?: string;
10
+ langs?: string[];
11
+ }
12
+ export declare function NavMenuGroup(item: NavMenuGroupItem): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Tag } from '@rspress/core/theme';
3
+ import { withoutBase, } from '@rspress/shared';
4
+ import { useState } from 'react';
5
+ import { SvgDown } from './Down.js';
6
+ import { NavMenuSingleItem } from './NavMenuSingleItem.js';
7
+ import { SvgWrapper } from './SvgWrapper.js';
8
+ function ActiveGroupItem({ item }) {
9
+ return (_jsxs("div", { className: "rounded-2xl my-1 flex", style: {
10
+ padding: '0.4rem 1.5rem 0.4rem 0.75rem',
11
+ }, children: [item.tag && _jsx(Tag, { tag: item.tag }), _jsx("span", { className: "text-brand", children: item.text })] }, item.link));
12
+ }
13
+ function NormalGroupItem({ item }) {
14
+ return (_jsx("div", { className: "font-medium my-1", children: _jsx("a", { href: item.link, children: _jsx("div", { className: "rounded-2xl hover:bg-mute", style: {
15
+ padding: '0.4rem 1.5rem 0.4rem 0.75rem',
16
+ }, children: _jsxs("div", { className: "flex", children: [item.tag && _jsx(Tag, { tag: item.tag }), _jsx("span", { children: item.text })] }) }) }) }, item.link));
17
+ }
18
+ export function NavMenuGroup(item) {
19
+ const { activeValue, items: groupItems, base = '', link = '', pathname = '', } = item;
20
+ const [isOpen, setIsOpen] = useState(false);
21
+ const renderLinkItem = (item) => {
22
+ const isLinkActive = new RegExp(item.activeMatch || item.link).test(withoutBase(pathname, base));
23
+ if (activeValue === item.text || (!activeValue && isLinkActive)) {
24
+ return _jsx(ActiveGroupItem, { item: item }, item.link);
25
+ }
26
+ return _jsx(NormalGroupItem, { item: item }, item.link);
27
+ };
28
+ const renderGroup = (item) => {
29
+ return (_jsxs("div", { children: ['link' in item ? (renderLinkItem(item)) : (_jsx("p", { className: "font-bold text-gray-400 my-1 not:first:border", children: item.text })), item.items.map(renderLinkItem)] }));
30
+ };
31
+ return (_jsxs("div", { className: "relative flex-center h-14", onMouseLeave: () => {
32
+ setIsOpen(false);
33
+ }, children: [_jsx("button", { onMouseEnter: () => {
34
+ setIsOpen(true);
35
+ }, className: "rspress-nav-menu-group-button flex-center items-center font-medium text-sm text-text-1 hover:text-text-2 transition-colors duration-200", children: link ? (
36
+ // @ts-expect-error item.text may be ReactElement
37
+ _jsx(NavMenuSingleItem, { ...item, rightIcon: _jsx(SvgWrapper, { icon: SvgDown }) })) : (_jsxs(_Fragment, { children: [_jsxs("span", { className: "text-sm font-medium flex", style: {
38
+ marginRight: '2px',
39
+ }, children: [_jsx(Tag, { tag: item.tag }), item.text] }), _jsx(SvgWrapper, { icon: SvgDown })] })) }), _jsx("div", { className: "rspress-nav-menu-group-content absolute mx-0.8 transition-opacity duration-300", style: {
40
+ opacity: isOpen ? 1 : 0,
41
+ visibility: isOpen ? 'visible' : 'hidden',
42
+ right: 0,
43
+ top: '52px',
44
+ }, children: _jsx("div", { className: "p-3 pr-2 w-full h-full max-h-100vh whitespace-nowrap", style: {
45
+ boxShadow: 'var(--rp-shadow-3)',
46
+ zIndex: 100,
47
+ border: '1px solid var(--rp-c-divider-light)',
48
+ borderRadius: 'var(--rp-radius-large)',
49
+ background: 'var(--rp-c-bg)',
50
+ }, children: groupItems.map((item) => {
51
+ return (_jsx("div", { children: 'items' in item ? renderGroup(item) : renderLinkItem(item) }, item.text));
52
+ }) }) })] }));
53
+ }
@@ -0,0 +1,10 @@
1
+ import { type NavItemWithLink, type NavItemWithLinkAndChildren } from '@rspress/shared';
2
+ interface Props {
3
+ pathname: string;
4
+ langs?: string[];
5
+ base: string;
6
+ rightIcon?: React.ReactNode;
7
+ compact?: boolean;
8
+ }
9
+ export declare function NavMenuSingleItem(item: (NavItemWithLink | NavItemWithLinkAndChildren) & Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Tag } from '@rspress/core/theme';
3
+ import { withoutBase, } from '@rspress/shared';
4
+ import styles from '../../../styles/versions-nav.module.scss';
5
+ export function NavMenuSingleItem(item) {
6
+ const { pathname, base } = item;
7
+ const isActive = new RegExp(item.activeMatch || item.link).test(withoutBase(pathname, base));
8
+ return (_jsx("a", { href: item.link, children: _jsxs("div", { className: `rspress-nav-menu-item ${styles.singleItem} ${isActive ? styles.activeItem : ''} text-sm font-medium ${item.compact ? 'mx-0.5' : 'mx-1.5'} px-3 py-2 flex items-center`, children: [_jsx(Tag, { tag: item.tag }), item.text, item.rightIcon] }, item.text) }));
9
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A wrapper for custom SVG icon.
3
+ * When the user uses a custom SVG, the imported icon can be a string or a React component.
4
+ */
5
+ export declare function SvgWrapper({ icon: Icon, ...rest }: {
6
+ icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
7
+ } & React.SVGAttributes<SVGSVGElement | HTMLImageElement>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * A wrapper for custom SVG icon.
4
+ * When the user uses a custom SVG, the imported icon can be a string or a React component.
5
+ */
6
+ export function SvgWrapper({ icon: Icon, ...rest }) {
7
+ if (!Icon) {
8
+ return null;
9
+ }
10
+ if (typeof Icon === 'string') {
11
+ return _jsx("img", { src: Icon, ...rest });
12
+ }
13
+ return _jsx(Icon, { ...rest });
14
+ }
@@ -0,0 +1,2 @@
1
+ export declare const VersionsNav: () => import("react").ReactPortal | null;
2
+ export default VersionsNav;
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { usePageData } from '@rspress/core/runtime';
3
+ import { noop } from 'es-toolkit';
4
+ import { useEffect, useMemo, useState } from 'react';
5
+ import { createPortal } from 'react-dom';
6
+ import { parse } from 'yaml';
7
+ import { NavMenuGroup } from './NavMenuGroup.js';
8
+ export const VersionsNav = () => {
9
+ const { siteData } = usePageData();
10
+ const [versionsBase, version] = useMemo(() => {
11
+ const parts = siteData.base.split('/');
12
+ const last = parts.at(-1);
13
+ return last === 'master' || /^v\d+\.\d$/.test(last)
14
+ ? [parts.slice(0, -1).join('/'), last]
15
+ : [];
16
+ }, [siteData.base]);
17
+ const [navMenu, setNavMenu] = useState();
18
+ const [versions, setVersions] = useState();
19
+ useEffect(() => {
20
+ const fetchVersions = async () => {
21
+ if (versionsBase == null) {
22
+ return;
23
+ }
24
+ const res = await fetch(`${versionsBase}/versions.yaml`);
25
+ const text = await res.text();
26
+ setNavMenu(document.querySelector('.rspress-nav-menu'));
27
+ setVersions(parse(text));
28
+ };
29
+ fetchVersions().catch(noop);
30
+ }, []);
31
+ // hack way to detect nav menu recreation on theme change
32
+ useEffect(() => {
33
+ if (!navMenu) {
34
+ return;
35
+ }
36
+ const observer = new MutationObserver((mutations) => {
37
+ if (mutations.some((m) => m.removedNodes.length)) {
38
+ setNavMenu(document.querySelector('.rspress-nav-menu'));
39
+ }
40
+ });
41
+ observer.observe(navMenu, { childList: true });
42
+ return () => {
43
+ observer.disconnect();
44
+ };
45
+ }, [navMenu]);
46
+ if (!versions?.length) {
47
+ return null;
48
+ }
49
+ return createPortal(_jsx(NavMenuGroup, { text: version, base: versionsBase, items: versions.map((v) => ({
50
+ text: v,
51
+ link: `${versionsBase}/${v}/`,
52
+ activeMatch: v,
53
+ })), pathname: siteData.base }), document.querySelector('.rspress-nav-menu'));
54
+ };
55
+ export default VersionsNav;
@@ -3,10 +3,10 @@ import { openapiSchemaToJsonSchema } from '@openapi-contrib/openapi-schema-to-js
3
3
  import { convertObj } from 'swagger2openapi';
4
4
  import { glob } from 'tinyglobby';
5
5
  import { resolveStaticConfig } from '../../utils/index.js';
6
- const crdsMap = {};
7
- const openapisMap = {};
8
- const shared = {};
9
6
  export const apiPlugin = () => {
7
+ const crdsMap = {};
8
+ const openapisMap = {};
9
+ const shared = {};
10
10
  return {
11
11
  name: 'doom-api',
12
12
  async beforeBuild(config_) {
@@ -3,9 +3,11 @@ import path from 'node:path';
3
3
  import { baseResolve, pkgResolve } from '../../utils/index.js';
4
4
  const componentsDir = baseResolve('runtime/components');
5
5
  export const globalPlugin = () => {
6
+ let config;
6
7
  return {
7
8
  name: 'doom-global',
8
9
  globalStyles: pkgResolve('styles/global.scss'),
10
+ globalUIComponents: [baseResolve('global/VersionsNav/index.tsx')],
9
11
  markdown: {
10
12
  globalComponents: fs
11
13
  .readdirSync(componentsDir)
@@ -17,5 +19,11 @@ export const globalPlugin = () => {
17
19
  })
18
20
  .map((file) => path.resolve(componentsDir, file)),
19
21
  },
22
+ beforeBuild(config_) {
23
+ config = config_;
24
+ },
25
+ extendPageData(pageData) {
26
+ pageData.sites = config.sites;
27
+ },
20
28
  };
21
29
  };
@@ -1 +1 @@
1
- export { Badge, Badge as default } from '@rspress/theme-default';
1
+ export { Badge, Badge as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Badge, Badge as default } from '@rspress/theme-default';
1
+ export { Badge, Badge as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Card, Card as default } from '@rspress/theme-default';
1
+ export { Card, Card as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Card, Card as default } from '@rspress/theme-default';
1
+ export { Card, Card as default } from '@rspress/core/theme';
@@ -0,0 +1,9 @@
1
+ export interface ExternalSiteProps {
2
+ name: string;
3
+ }
4
+ export interface ExternalSiteNoteProps {
5
+ name: string;
6
+ href: string;
7
+ }
8
+ export declare const ExternalSite: ({ name }: ExternalSiteProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default ExternalSite;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useLang, usePageData } from '@rspress/core/runtime';
3
+ import { addTrailingSlash } from '@rspress/shared';
4
+ import { useMemo } from 'react';
5
+ import { handleCJKWhitespaces } from '../utils.js';
6
+ import { Directive } from './_Directive.js';
7
+ const Notes = {
8
+ en({ name, href }) {
9
+ return (_jsxs(_Fragment, { children: ["Because ", name, " releases on a different cadence from Alauda Container Platform, the ", name, " documentation is now available as a separate documentation set at", ' ', _jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", children: name }), "."] }));
10
+ },
11
+ zh({ name, href }) {
12
+ const name_ = handleCJKWhitespaces(name);
13
+ return (_jsxs(_Fragment, { children: ["\u56E0\u4E3A", name_, "\u7684\u53D1\u7248\u5468\u671F\u4E0E\u7075\u96C0\u4E91\u5BB9\u5668\u5E73\u53F0\u4E0D\u540C\uFF0C\u6240\u4EE5", name_, "\u7684\u6587\u6863\u73B0\u5728\u4F5C\u4E3A\u72EC\u7ACB\u7684\u6587\u6863\u7AD9\u70B9\u6258\u7BA1\u5728", name_.startsWith(' ') ? ' ' : '', _jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", children: name }), "\u3002"] }));
14
+ },
15
+ };
16
+ export const ExternalSite = ({ name }) => {
17
+ const { siteData, page } = usePageData();
18
+ const site = useMemo(() => page.sites?.find((s) => s.name === name), []);
19
+ const fallbackLang = siteData.lang || 'zh';
20
+ const lang = useLang() || fallbackLang;
21
+ const displayName = useMemo(() => site?.displayName?.[lang] || site?.displayName?.[fallbackLang] || name, []);
22
+ if (!site) {
23
+ return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
24
+ }
25
+ const Note = Notes[lang] || Notes[fallbackLang] || Notes.en;
26
+ return (_jsx(Directive, { title: "Note", children: _jsx(Note, { name: displayName, href: addTrailingSlash(site.base) }) }));
27
+ };
28
+ export default ExternalSite;
@@ -6,8 +6,8 @@ import { usePageData } from '@rspress/core/runtime';
6
6
  import { Badge, Button, getCustomMDXComponent } from '@rspress/core/theme';
7
7
  import { useCallback, useEffect, useMemo, useState } from 'react';
8
8
  import { useTranslation } from '../hooks/index.js';
9
+ import { Directive } from './_Directive.js';
9
10
  import { Markdown } from './_Markdown.js';
10
- import Directive from './Directive.js';
11
11
  const X = getCustomMDXComponent();
12
12
  export const K8sCrdSchemaPart = ({ name, parent, schema: property, openAll, }) => {
13
13
  const [open, setOpen] = useState(openAll);
@@ -1 +1 @@
1
- export { LinkCard, LinkCard as default } from '@rspress/theme-default';
1
+ export { LinkCard, LinkCard as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { LinkCard, LinkCard as default } from '@rspress/theme-default';
1
+ export { LinkCard, LinkCard as default } from '@rspress/core/theme';
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { usePageData } from '@rspress/core/runtime';
3
- import { getCustomMDXComponent } from '@rspress/theme-default';
3
+ import { getCustomMDXComponent } from '@rspress/core/theme';
4
4
  import { useMemo } from 'react';
5
5
  import { DEFAULT_COMMON_REFS, modelName, omitRoutePathRefs, resolveRef, } from '../utils.js';
6
6
  import { HeadingTitle } from './_HeadingTitle.js';
@@ -1 +1 @@
1
- export { PackageManagerTabs, PackageManagerTabs as default, } from '@rspress/theme-default';
1
+ export { PackageManagerTabs, PackageManagerTabs as default, } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { PackageManagerTabs, PackageManagerTabs as default, } from '@rspress/theme-default';
1
+ export { PackageManagerTabs, PackageManagerTabs as default, } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Steps, Steps as default } from '@rspress/theme-default';
1
+ export { Steps, Steps as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Steps, Steps as default } from '@rspress/theme-default';
1
+ export { Steps, Steps as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Tab, Tab as default } from '@rspress/theme-default';
1
+ export { Tab, Tab as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Tab, Tab as default } from '@rspress/theme-default';
1
+ export { Tab, Tab as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Tabs, Tabs as default } from '@rspress/theme-default';
1
+ export { Tabs, Tabs as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Tabs, Tabs as default } from '@rspress/theme-default';
1
+ export { Tabs, Tabs as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Toc, Toc as default } from '@rspress/theme-default';
1
+ export { Toc, Toc as default } from '@rspress/core/theme';
@@ -1 +1 @@
1
- export { Toc, Toc as default } from '@rspress/theme-default';
1
+ export { Toc, Toc as default } from '@rspress/core/theme';
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ export interface DirectiveProps {
3
+ type?: 'danger' | 'details' | 'info' | 'note' | 'tip' | 'warning';
4
+ children: ReactNode;
5
+ className?: string;
6
+ title?: ReactNode;
7
+ open?: boolean;
8
+ onToggle?: (open: boolean) => void;
9
+ }
10
+ export declare const Directive: ({ className, type, title, children, open, onToggle, }: DirectiveProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { clsx } from 'clsx';
3
+ import { upperCase } from 'es-toolkit';
4
+ import { useCallback } from 'react';
5
+ export const Directive = ({ className, type = 'info', title, children, open, onToggle, }) => {
6
+ const rootClassName = clsx('rspress-directive', type, className);
7
+ const titleNode = title || upperCase(type);
8
+ const contentNode = (_jsx("div", { className: "rspress-directive-content", children: children }));
9
+ const handleToggle = useCallback((ev) => {
10
+ onToggle?.(ev.currentTarget.open);
11
+ }, [onToggle]);
12
+ if (type === 'details') {
13
+ return (_jsxs("details", { className: rootClassName, open: open, onToggle: handleToggle, children: [_jsx("summary", { className: "rspress-directive-title", children: titleNode }), contentNode] }));
14
+ }
15
+ return (_jsxs("div", { className: rootClassName, children: [_jsx("div", { className: "rspress-directive-title", children: titleNode }), contentNode] }));
16
+ };
@@ -1,12 +1,13 @@
1
1
  export * from './Badge.js';
2
2
  export * from './Callouts.js';
3
3
  export * from './Card.js';
4
+ export * from './ExternalSite.js';
4
5
  export * from './K8sCrd.js';
5
6
  export * from './LinkCard.js';
6
7
  export * from './Overview.js';
7
- export * from './PackageManagerTabs.js';
8
8
  export * from './OpenAPIRef.js';
9
9
  export * from './OpenAPIPath.js';
10
+ export * from './PackageManagerTabs.js';
10
11
  export * from './QuickNav.js';
11
12
  export * from './Steps.js';
12
13
  export * from './Tab.js';
@@ -1,12 +1,13 @@
1
1
  export * from './Badge.js';
2
2
  export * from './Callouts.js';
3
3
  export * from './Card.js';
4
+ export * from './ExternalSite.js';
4
5
  export * from './K8sCrd.js';
5
6
  export * from './LinkCard.js';
6
7
  export * from './Overview.js';
7
- export * from './PackageManagerTabs.js';
8
8
  export * from './OpenAPIRef.js';
9
9
  export * from './OpenAPIPath.js';
10
+ export * from './PackageManagerTabs.js';
10
11
  export * from './QuickNav.js';
11
12
  export * from './Steps.js';
12
13
  export * from './Tab.js';
@@ -1,11 +1,13 @@
1
1
  import { PageData } from '@rspress/core';
2
2
  import { OpenAPIV3_1 } from 'openapi-types';
3
3
  import type { CustomResourceDefinition } from '../plugins/api/types.js';
4
+ import { DoomSite } from '../utils/types.js';
4
5
  export interface ExtendedPage {
5
6
  crdsMap?: Record<string, CustomResourceDefinition>;
6
7
  openapisMap?: Record<string, OpenAPIV3_1.Document>;
7
8
  references?: Record<string, string>;
8
9
  pathPrefix?: string;
10
+ sites?: DoomSite[];
9
11
  }
10
12
  export interface ExtendedPageData extends PageData {
11
13
  page: PageData['page'] & ExtendedPage;
@@ -7,3 +7,5 @@ export declare const DEFAULT_COMMON_REFS: {
7
7
  export declare const omitRoutePathRefs: (refs: Record<string, string>, routePath: string) => {
8
8
  [k: string]: string;
9
9
  };
10
+ export declare const CJK_PATTERN: RegExp;
11
+ export declare const handleCJKWhitespaces: (text: string) => string;
@@ -17,3 +17,8 @@ export const DEFAULT_COMMON_REFS = Object.fromEntries(Object.entries(DEFAULT_COM
17
17
  `${K8S_DOC_PREFIX}${value}`,
18
18
  ]));
19
19
  export const omitRoutePathRefs = (refs, routePath) => Object.fromEntries(Object.entries(refs).filter(([, value]) => routePath !== value.split('#')[0]));
20
+ export const CJK_PATTERN = /\p{sc=Han}/u;
21
+ export const handleCJKWhitespaces = (text) => {
22
+ text = text.at(0)?.match(CJK_PATTERN) ? text : ` ${text}`;
23
+ return text.at(-1)?.match(CJK_PATTERN) ? text : `${text} `;
24
+ };
@@ -1,4 +1,11 @@
1
1
  import { UserConfig } from '@rspress/core';
2
+ export interface DoomSite {
3
+ name: string;
4
+ displayName?: Record<string, string>;
5
+ repo: string;
6
+ base: string;
7
+ defaultVersion?: string;
8
+ }
2
9
  export interface DoomConfig extends UserConfig {
3
10
  api?: {
4
11
  crds?: string[];
@@ -6,4 +13,5 @@ export interface DoomConfig extends UserConfig {
6
13
  references?: Record<string, string>;
7
14
  pathPrefix?: string;
8
15
  };
16
+ sites?: DoomSite[];
9
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -64,6 +64,7 @@
64
64
  "@types/eslint__js": "^8.42.3",
65
65
  "@types/fs-extra": "^11.0.4",
66
66
  "@types/node": "^18.19.68",
67
+ "@types/react-dom": "^18.3.5",
67
68
  "@types/swagger2openapi": "^7.0.4",
68
69
  "eslint": "^9.17.0",
69
70
  "lint-staged": "^15.2.11",
@@ -0,0 +1,11 @@
1
+ .singleItem {
2
+ word-break: keep-all;
3
+ }
4
+
5
+ .activeItem,
6
+ .singleItem:hover {
7
+ background-color: var(--rp-c-bg-mute);
8
+ cursor: pointer;
9
+ color: var(--rp-c-link);
10
+ border-radius: var(--rp-radius);
11
+ }