@alauda/doom 2.11.3 → 2.11.4
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RspressPlugin } from '@rspress/core';
|
|
2
2
|
import { type DoomSite } from '../../shared/index.ts';
|
|
3
|
-
import type { ExportItem } from '../../types.ts';
|
|
3
|
+
import type { ExportItem, ProductsOverviewOptions } from '../../types.ts';
|
|
4
4
|
export interface GlobalPluginOptions {
|
|
5
5
|
version?: string;
|
|
6
6
|
download?: boolean;
|
|
@@ -8,6 +8,7 @@ export interface GlobalPluginOptions {
|
|
|
8
8
|
export interface GlobalVirtual extends GlobalPluginOptions {
|
|
9
9
|
userBase: string;
|
|
10
10
|
prefix?: string;
|
|
11
|
+
productsOverview?: ProductsOverviewOptions;
|
|
11
12
|
sites?: DoomSite[];
|
|
12
13
|
export?: ExportItem[];
|
|
13
14
|
sidebarManifestUrl?: string;
|
|
@@ -46,6 +46,7 @@ export const globalPlugin = ({ version, download, }) => {
|
|
|
46
46
|
'doom-@global-virtual': `export default ${JSON.stringify({
|
|
47
47
|
userBase: config.userBase,
|
|
48
48
|
prefix: config.prefix,
|
|
49
|
+
productsOverview: config.productsOverview,
|
|
49
50
|
version,
|
|
50
51
|
download,
|
|
51
52
|
sites: config.sites?.map((site) => ({
|
package/lib/products/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { addLeadingSlash, NoSSR, useSite } from '@rspress/core/runtime';
|
|
2
|
+
import { addLeadingSlash, NoSSR, useHead, useSite } from '@rspress/core/runtime';
|
|
3
3
|
import virtual from 'doom-@global-virtual';
|
|
4
4
|
import { use } from 'react';
|
|
5
5
|
import { BuildInfoContext } from "../shared/context.js";
|
|
6
6
|
import { isUnversioned } from '../shared/helpers.js';
|
|
7
|
+
import { getProductsOverviewCanonical, getProductsOverviewUrl } from "./url.js";
|
|
7
8
|
import { useIsPrint, useLang, useTranslation } from '@alauda/doom/runtime';
|
|
8
9
|
import classes from '@alauda/doom/styles/products.module.scss';
|
|
9
10
|
const Products = () => {
|
|
@@ -20,6 +21,14 @@ const Products = () => {
|
|
|
20
21
|
item.base }) }, item.base))) })] }, group.id))) }));
|
|
21
22
|
};
|
|
22
23
|
export default () => {
|
|
24
|
+
const lang = useLang();
|
|
23
25
|
const t = useTranslation();
|
|
24
|
-
|
|
26
|
+
const productsOverviewCanonical = getProductsOverviewCanonical(virtual.productsOverview, virtual.prefix);
|
|
27
|
+
const productsOverviewUrl = getProductsOverviewUrl(virtual.productsOverview, lang, virtual.prefix);
|
|
28
|
+
useHead({
|
|
29
|
+
link: productsOverviewCanonical
|
|
30
|
+
? [{ rel: 'canonical', href: productsOverviewCanonical }]
|
|
31
|
+
: [],
|
|
32
|
+
});
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsx("h1", { children: t('all_product_documentation') }), _jsx("p", { children: t('explore_doc_all_products') }), productsOverviewUrl && (_jsx("p", { children: _jsx("a", { className: "rp-link", href: productsOverviewUrl, children: t('all_product_documentation') }) })), _jsx(NoSSR, { children: _jsx(Products, {}) })] }));
|
|
25
34
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProductsOverviewOptions } from '../types.ts';
|
|
2
|
+
export declare const getProductsOverviewUrl: (options: ProductsOverviewOptions | undefined, lang: string, prefix?: string) => string;
|
|
3
|
+
export declare const getProductsOverviewCanonical: (options: ProductsOverviewOptions | undefined, prefix?: string) => string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const URL_BASE = 'https://doom.invalid';
|
|
2
|
+
const defaultProductsOverviewUrl = (prefix) => {
|
|
3
|
+
const normalizedPrefix = prefix?.replace(/\/+$/, '') ?? '';
|
|
4
|
+
return `${normalizedPrefix}/products/`;
|
|
5
|
+
};
|
|
6
|
+
const parseOverviewUrl = (options) => {
|
|
7
|
+
const { url } = options;
|
|
8
|
+
const parsed = new URL(url, URL_BASE);
|
|
9
|
+
let isAbsolute = false;
|
|
10
|
+
try {
|
|
11
|
+
isAbsolute = Boolean(new URL(url).protocol);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// The URL is checked as a root-relative path below.
|
|
15
|
+
}
|
|
16
|
+
const isRootRelative = url.startsWith('/') && !url.startsWith('//');
|
|
17
|
+
if (!isAbsolute && !isRootRelative) {
|
|
18
|
+
throw new Error('`productsOverview.url` must be an absolute URL or a root-relative path');
|
|
19
|
+
}
|
|
20
|
+
return parsed;
|
|
21
|
+
};
|
|
22
|
+
const serializeUrl = (url, isRelative) => isRelative ? `${url.pathname}${url.search}${url.hash}` : url.toString();
|
|
23
|
+
export const getProductsOverviewUrl = (options, lang, prefix) => {
|
|
24
|
+
const configuredUrl = options?.url ?? defaultProductsOverviewUrl(prefix);
|
|
25
|
+
const isRelative = configuredUrl.startsWith('/');
|
|
26
|
+
const url = parseOverviewUrl({ url: configuredUrl });
|
|
27
|
+
url.searchParams.set('lang', lang);
|
|
28
|
+
return serializeUrl(url, isRelative);
|
|
29
|
+
};
|
|
30
|
+
export const getProductsOverviewCanonical = (options, prefix) => {
|
|
31
|
+
const configuredUrl = options?.url ?? defaultProductsOverviewUrl(prefix);
|
|
32
|
+
const isRelative = configuredUrl.startsWith('/');
|
|
33
|
+
return serializeUrl(parseOverviewUrl({ url: configuredUrl }), isRelative);
|
|
34
|
+
};
|
|
@@ -5,6 +5,7 @@ import virtual from 'doom-@global-virtual';
|
|
|
5
5
|
import { use, useEffect, useMemo } from 'react';
|
|
6
6
|
import { xfetch } from 'x-fetch';
|
|
7
7
|
import { parse } from 'yaml';
|
|
8
|
+
import { getProductsOverviewUrl } from "../../products/url.js";
|
|
8
9
|
import { BuildInfoContext } from "../../shared/context.js";
|
|
9
10
|
import { X } from "../_X.js";
|
|
10
11
|
import { useLang, useSiteOverrides, useTranslation } from '@alauda/doom/runtime';
|
|
@@ -43,6 +44,7 @@ export const BreadCrumb = () => {
|
|
|
43
44
|
return walk(sidebar);
|
|
44
45
|
}, [pathname, sidebar]);
|
|
45
46
|
const prefix = addTrailingSlash(`/${lang === siteData.lang ? '' : lang}`);
|
|
47
|
+
const productsOverviewUrl = getProductsOverviewUrl(virtual.productsOverview, lang, virtual.prefix);
|
|
46
48
|
const { groups, setGroups: setBuildInfoGroups } = use(BuildInfoContext);
|
|
47
49
|
const hasGroups = !!groups.length;
|
|
48
50
|
useEffect(() => {
|
|
@@ -86,6 +88,6 @@ export const BreadCrumb = () => {
|
|
|
86
88
|
};
|
|
87
89
|
void fetchBuildInfo();
|
|
88
90
|
}, [setBuildInfoGroups]);
|
|
89
|
-
return (_jsx("div", { className: "breadcrumb-container", children: _jsxs("ul", { className: "breadcrumb-content", children: [hasGroups && (_jsx("li", { className: "breadcrumb-item rp-doc", children: _jsx(
|
|
91
|
+
return (_jsx("div", { className: "breadcrumb-container", children: _jsxs("ul", { className: "breadcrumb-content", children: [hasGroups && (_jsx("li", { className: "breadcrumb-item rp-doc", children: _jsx("a", { href: productsOverviewUrl, children: t('products') }) })), _jsxs("li", { className: "breadcrumb-item rp-doc", children: [hasGroups && _jsx(SvgWrapper, { icon: IconArrowRight }), _jsx(X.a, { href: prefix, children: site.title || siteData.title })] }), breadcrumbItems?.map((item, index) => (_jsxs("li", { className: "breadcrumb-item rp-doc", children: [_jsx(SvgWrapper, { icon: IconArrowRight }), item.link ? (_jsx(X.a, { href: item.link, children: item.text })) : (_jsx("span", { className: "breadcrumb-item-text", children: item.text }))] }, index)))] }) }));
|
|
90
92
|
};
|
|
91
93
|
export default BreadCrumb;
|
package/lib/types.d.ts
CHANGED
|
@@ -201,6 +201,16 @@ export interface AlgoliaOptions {
|
|
|
201
201
|
apiKey: string;
|
|
202
202
|
indexName: string;
|
|
203
203
|
}
|
|
204
|
+
export interface ProductsOverviewOptions {
|
|
205
|
+
/**
|
|
206
|
+
* The deployment's outer products overview URL. It may be an absolute URL
|
|
207
|
+
* or a root-relative path such as `/products/` or `/docs/products/`.
|
|
208
|
+
* The value is used as-is for the Products link and canonical URL. If the
|
|
209
|
+
* overview is a directory index, include a trailing slash because the page
|
|
210
|
+
* loads its stylesheets with relative paths.
|
|
211
|
+
*/
|
|
212
|
+
url: string;
|
|
213
|
+
}
|
|
204
214
|
export interface ExportItem {
|
|
205
215
|
name?: string;
|
|
206
216
|
scope: string | string[];
|
|
@@ -225,6 +235,7 @@ declare module '@rspress/shared' {
|
|
|
225
235
|
lint?: LintOptions;
|
|
226
236
|
algolia?: AlgoliaOptions;
|
|
227
237
|
siteUrl?: string;
|
|
238
|
+
productsOverview?: ProductsOverviewOptions;
|
|
228
239
|
export?: ExportItem[];
|
|
229
240
|
}
|
|
230
241
|
interface SiteData {
|