@takazudo/zudo-doc 1.3.0 → 2.0.0
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/dist/chrome/derive.d.ts +68 -0
- package/dist/chrome/derive.js +231 -0
- package/dist/chrome/index.d.ts +37 -0
- package/dist/chrome/index.js +43 -0
- package/dist/doc-body-end/index.d.ts +9 -11
- package/dist/doc-body-end/index.js +4 -2
- package/dist/doc-content-header/index.d.ts +10 -2
- package/dist/doc-content-header/index.js +8 -8
- package/dist/doc-history-area/index.d.ts +10 -25
- package/dist/doc-history-area/index.js +14 -10
- package/dist/doc-metainfo-area/index.d.ts +9 -15
- package/dist/doc-metainfo-area/index.js +6 -2
- package/dist/doc-page-renderer/index.d.ts +11 -2
- package/dist/doc-page-renderer/index.js +22 -15
- package/dist/doc-page-shell/index.d.ts +11 -3
- package/dist/doc-page-shell/index.js +21 -14
- package/dist/doc-pager/index.d.ts +6 -7
- package/dist/doc-pager/index.js +2 -2
- package/dist/doc-route-entries/index.d.ts +22 -46
- package/dist/doc-route-entries/index.js +15 -10
- package/dist/doc-tags-area/index.d.ts +9 -19
- package/dist/doc-tags-area/index.js +12 -2
- package/dist/factory-context/index.d.ts +163 -1
- package/dist/footer-with-defaults/index.d.ts +12 -13
- package/dist/footer-with-defaults/index.js +8 -10
- package/dist/head-with-defaults/index.d.ts +12 -16
- package/dist/head-with-defaults/index.js +7 -9
- package/dist/header-with-defaults/index.d.ts +10 -31
- package/dist/header-with-defaults/index.js +15 -18
- package/dist/nav-source-docs/index.d.ts +20 -54
- package/dist/nav-source-docs/index.js +9 -10
- package/dist/route-context/index.d.ts +24 -0
- package/dist/route-context/index.js +147 -0
- package/dist/route-enumerators/index.d.ts +25 -74
- package/dist/route-enumerators/index.js +17 -18
- package/dist/routes/_chrome.d.ts +6 -25
- package/dist/routes/_chrome.js +14 -387
- package/dist/routes/_context.d.ts +10 -43
- package/dist/routes/_context.js +29 -157
- package/dist/sidebar-with-defaults/index.d.ts +8 -15
- package/dist/sidebar-with-defaults/index.js +6 -10
- package/dist/tag-pages/index.d.ts +12 -3
- package/dist/tag-pages/index.js +24 -19
- package/dist/versions-page/index.d.ts +10 -3
- package/dist/versions-page/index.js +18 -14
- package/eject/doc-pager/index.tsx +8 -10
- package/package.json +9 -1
- package/routes-src/_chrome.tsx +31 -552
- package/routes-src/_context.ts +37 -269
|
@@ -2,15 +2,13 @@ import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
|
2
2
|
import { OgTags, TwitterCard } from "../head/index.js";
|
|
3
3
|
import { SIDEBAR_RESIZER_RESTORE_SCRIPT } from "../sidebar-resizer/index.js";
|
|
4
4
|
import ColorSchemeProvider from "../theme/color-scheme-provider.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
generateLightDarkCssProperties
|
|
13
|
-
} = deps;
|
|
5
|
+
import { deriveComposeMetaTitle, deriveColorSchemeGenerators } from "../chrome/derive.js";
|
|
6
|
+
function createHeadWithDefaults(ctx) {
|
|
7
|
+
const settings = ctx.settings;
|
|
8
|
+
const composeMetaTitle = deriveComposeMetaTitle(ctx);
|
|
9
|
+
const withBase = ctx.withBase;
|
|
10
|
+
const absoluteUrl = ctx.absoluteUrl;
|
|
11
|
+
const { generateCssCustomProperties, generateLightDarkCssProperties } = deriveColorSchemeGenerators(ctx);
|
|
14
12
|
function HeadWithDefaults({
|
|
15
13
|
title,
|
|
16
14
|
description,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** @jsxRuntime automatic */
|
|
2
2
|
/** @jsxImportSource preact */
|
|
3
3
|
import type { JSX } from "preact";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
4
|
+
import type { ChromeContext } from "../factory-context/index.js";
|
|
5
|
+
import type { Settings } from "../settings.js";
|
|
6
6
|
export interface HeaderWithDefaultsProps {
|
|
7
7
|
/** Active locale; defaults to the configured defaultLocale. */
|
|
8
8
|
lang?: string;
|
|
@@ -44,34 +44,13 @@ export interface HeaderWithDefaultsSettings {
|
|
|
44
44
|
versions?: HeaderVersionEntry[] | false;
|
|
45
45
|
githubUrl?: string | false;
|
|
46
46
|
}
|
|
47
|
-
/** Dependencies injected by the host stub. */
|
|
48
|
-
export interface HeaderWithDefaultsDeps {
|
|
49
|
-
settings: HeaderWithDefaultsSettings;
|
|
50
|
-
defaultLocale: string;
|
|
51
|
-
locales: readonly string[];
|
|
52
|
-
t: (key: string, lang: string) => string;
|
|
53
|
-
withBase: (path: string) => string;
|
|
54
|
-
stripBase: (path: string) => string;
|
|
55
|
-
docsUrl: (slug: string, lang: string) => string;
|
|
56
|
-
navHref: (path: string, lang: string | undefined, version: string | undefined) => string;
|
|
57
|
-
versionedDocsUrl: (slug: string, versionSlug: string, lang: string) => string;
|
|
58
|
-
buildLocaleLinksForNav: (currentPath: string, lang: string, localeCount: number) => LocaleLink[] | undefined;
|
|
59
|
-
buildRootMenuItems: (lang: string, currentVersion: string | undefined) => SidebarRootMenuItem[];
|
|
60
|
-
buildSidebarNodes: (lang: string, navSection: string | undefined, currentVersion: string | undefined) => SidebarNavNode[];
|
|
61
|
-
getThemeDefaultMode: () => "light" | "dark" | undefined;
|
|
62
|
-
buildGitHubRepoUrl: () => string | null;
|
|
63
|
-
SearchWidget: (props: {
|
|
64
|
-
placeholderText: string;
|
|
65
|
-
shortcutHint: string;
|
|
66
|
-
resultCountTemplate: string;
|
|
67
|
-
searchLabel: string;
|
|
68
|
-
searchUnavailableText: string;
|
|
69
|
-
loadingIndexText: string;
|
|
70
|
-
noResultsText: string;
|
|
71
|
-
}) => JSX.Element;
|
|
72
|
-
}
|
|
73
47
|
/**
|
|
74
|
-
* Create a `HeaderWithDefaults` component
|
|
75
|
-
*
|
|
48
|
+
* Create a `HeaderWithDefaults` component from the unified {@link ChromeContext}
|
|
49
|
+
* (epic Collapse Wiring Shells #2420, FACTORIES #2424 — breaking signature).
|
|
50
|
+
*
|
|
51
|
+
* Derives its old wide deps bag from the context: the URL/i18n helpers
|
|
52
|
+
* (`t`/`withBase`/`docsUrl`/…) and `locales`/`defaultLocale` are read directly;
|
|
53
|
+
* the nav data-prep builders + SearchWidget slot come from the shared
|
|
54
|
+
* `chrome/derive` helpers; `buildGitHubRepoUrl` is bound to `settings.githubUrl`.
|
|
76
55
|
*/
|
|
77
|
-
export declare function createHeaderWithDefaults(
|
|
56
|
+
export declare function createHeaderWithDefaults<S extends Settings = Settings>(ctx: ChromeContext<S>): (props: HeaderWithDefaultsProps) => JSX.Element;
|
|
@@ -7,24 +7,21 @@ import {
|
|
|
7
7
|
} from "../i18n-version/index.js";
|
|
8
8
|
import { ThemeToggle } from "../theme-toggle/index.js";
|
|
9
9
|
import { SidebarToggle } from "../sidebar-toggle-island/index.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
buildGitHubRepoUrl,
|
|
26
|
-
SearchWidget
|
|
27
|
-
} = deps;
|
|
10
|
+
import { buildGitHubRepoUrl as buildGitHubRepoUrlBase } from "../github-helpers/index.js";
|
|
11
|
+
import { deriveNavDataPrep, deriveSearchWidgetSlot } from "../chrome/derive.js";
|
|
12
|
+
function createHeaderWithDefaults(ctx) {
|
|
13
|
+
const settings = ctx.settings;
|
|
14
|
+
const defaultLocale = ctx.defaultLocale;
|
|
15
|
+
const locales = ctx.locales;
|
|
16
|
+
const t = ctx.t;
|
|
17
|
+
const withBase = ctx.withBase;
|
|
18
|
+
const stripBase = ctx.stripBase;
|
|
19
|
+
const docsUrl = ctx.docsUrl;
|
|
20
|
+
const navHref = ctx.navHref;
|
|
21
|
+
const versionedDocsUrl = ctx.versionedDocsUrl;
|
|
22
|
+
const { buildRootMenuItems, buildLocaleLinksForNav, buildSidebarNodes, getThemeDefaultMode } = deriveNavDataPrep(ctx);
|
|
23
|
+
const buildGitHubRepoUrl = () => buildGitHubRepoUrlBase(ctx.settings.githubUrl);
|
|
24
|
+
const SearchWidget = deriveSearchWidgetSlot(ctx);
|
|
28
25
|
function HeaderWithDefaults(props) {
|
|
29
26
|
const {
|
|
30
27
|
lang: langProp = defaultLocale,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CategoryMeta } from "../sidebar-tree/index.js";
|
|
2
2
|
import type { DocPageEntry } from "../doc-page-props/index.js";
|
|
3
|
+
import type { Settings } from "../settings.js";
|
|
3
4
|
export type { CategoryMeta, DocPageEntry };
|
|
4
5
|
export interface NavSourceDocs {
|
|
5
6
|
/** Full doc list (merged + draft-filtered; unlisted retained per options). */
|
|
@@ -41,58 +42,32 @@ export interface VersionConfigEntry {
|
|
|
41
42
|
}>;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
+
* Context slice `createNavSourceDocs` derives its bag from (epic Collapse
|
|
46
|
+
* Wiring Shells #2420, FACTORIES #2424 — breaking signature). This is a
|
|
47
|
+
* STRUCTURAL SUBSET of the unified `RouteContext`/`ChromeContext`, so callers
|
|
48
|
+
* pass the whole context: `docsDir`/`getVersions` are read off `settings`,
|
|
49
|
+
* `loadCategoryMeta` is imported from the package directly (it is a pure,
|
|
50
|
+
* `@/`-free helper), and the rest are reconstructed callables on the context.
|
|
45
51
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
52
|
+
* NB: `createRouteContext` builds the route context incrementally and calls
|
|
53
|
+
* this factory with the partial-but-sufficient base context — every field
|
|
54
|
+
* below is present before the nav-source resolvers are assembled.
|
|
49
55
|
*/
|
|
50
56
|
export interface NavSourceDocsContext {
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
57
|
+
/** The host's resolved settings object (reads `docsDir` + `versions`). */
|
|
58
|
+
settings: Settings;
|
|
59
|
+
/** Default locale code (un-prefixed `/docs/...` routes). E.g. `"en"`. */
|
|
55
60
|
defaultLocale: string;
|
|
56
|
-
/**
|
|
57
|
-
* The configured docs content directory (e.g. `"src/content/docs"`).
|
|
58
|
-
* Used as the base dir for `loadCategoryMeta`.
|
|
59
|
-
*/
|
|
60
|
-
docsDir: string;
|
|
61
|
-
/**
|
|
62
|
-
* Getter for the configured versions list (or false if versioning is not
|
|
63
|
-
* active). Called on every `resolveNavSource` invocation so test code that
|
|
64
|
-
* mutates `settings.versions` between calls sees the updated value.
|
|
65
|
-
* Structural equivalent of a getter for `settings.versions`.
|
|
66
|
-
*
|
|
67
|
-
* Pass `() => settings.versions` from the host stub.
|
|
68
|
-
*/
|
|
69
|
-
getVersions: () => VersionConfigEntry[] | false | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Look up locale-specific config (dir, etc.) for a locale code.
|
|
72
|
-
* Host passes `getLocaleConfig` from `@/config/i18n`.
|
|
73
|
-
*/
|
|
61
|
+
/** Per-locale config lookup (reconstructed on the context). */
|
|
74
62
|
getLocaleConfig: (lang: string) => LocaleConfig | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* Load category metadata for a content dir.
|
|
77
|
-
* Host passes `loadCategoryMeta` from `@/utils/docs` (re-exported from
|
|
78
|
-
* `@takazudo/zudo-doc/sidebar-tree`).
|
|
79
|
-
*/
|
|
80
|
-
loadCategoryMeta: (dir: string) => Map<string, CategoryMeta>;
|
|
81
|
-
/**
|
|
82
|
-
* Filter predicate: true when a doc should appear in navigation.
|
|
83
|
-
* Host passes `isNavVisible` from `@/utils/docs`.
|
|
84
|
-
*/
|
|
63
|
+
/** Filter predicate: true when a doc should appear in navigation. */
|
|
85
64
|
isNavVisible: (doc: DocPageEntry) => boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Returns true for paths that are only shown in the default locale.
|
|
88
|
-
* Host passes `isDefaultLocaleOnlyPath` from `@/utils/base`.
|
|
89
|
-
*/
|
|
65
|
+
/** Returns true for paths that are only shown in the default locale. */
|
|
90
66
|
isDefaultLocaleOnlyPath: (path: string) => boolean;
|
|
91
67
|
/**
|
|
92
|
-
* Identity-stable, draft-filtered docs array for a collection
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* array instance is returned on every call within one build.
|
|
68
|
+
* Identity-stable, draft-filtered docs array for a collection (the
|
|
69
|
+
* content-bridge handle). Anchors memoization on the zfb snapshot so the
|
|
70
|
+
* SAME array instance is returned on every call within one build.
|
|
96
71
|
*/
|
|
97
72
|
stableDocs: (collectionName: string) => DocPageEntry[];
|
|
98
73
|
}
|
|
@@ -154,16 +129,7 @@ export interface NavSourceDocsAPI {
|
|
|
154
129
|
* loadNavSourceDocs,
|
|
155
130
|
* stableMergeCategoryMeta,
|
|
156
131
|
* stableNavDocs,
|
|
157
|
-
* } = createNavSourceDocs(
|
|
158
|
-
* defaultLocale,
|
|
159
|
-
* docsDir: settings.docsDir,
|
|
160
|
-
* getVersions: () => settings.versions,
|
|
161
|
-
* getLocaleConfig,
|
|
162
|
-
* loadCategoryMeta,
|
|
163
|
-
* isNavVisible,
|
|
164
|
-
* isDefaultLocaleOnlyPath,
|
|
165
|
-
* stableDocs,
|
|
166
|
-
* });
|
|
132
|
+
* } = createNavSourceDocs(routeContext);
|
|
167
133
|
* ```
|
|
168
134
|
*/
|
|
169
135
|
export declare function createNavSourceDocs(ctx: NavSourceDocsContext): NavSourceDocsAPI;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { loadCategoryMeta as loadCategoryMetaImpl } from "../sidebar-tree/index.js";
|
|
1
2
|
import { memoizeDerived } from "../nav-source-cache/index.js";
|
|
2
3
|
import { mergeLocaleDocs } from "../locale-merge/index.js";
|
|
3
4
|
function optionSig(o) {
|
|
@@ -5,16 +6,14 @@ function optionSig(o) {
|
|
|
5
6
|
}
|
|
6
7
|
const EMPTY_SLUG_SET = /* @__PURE__ */ new Set();
|
|
7
8
|
function createNavSourceDocs(ctx) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
stableDocs
|
|
17
|
-
} = ctx;
|
|
9
|
+
const defaultLocale = ctx.defaultLocale;
|
|
10
|
+
const docsDir = ctx.settings.docsDir;
|
|
11
|
+
const getVersions = () => ctx.settings.versions;
|
|
12
|
+
const getLocaleConfig = ctx.getLocaleConfig;
|
|
13
|
+
const loadCategoryMeta = loadCategoryMetaImpl;
|
|
14
|
+
const isNavVisible = ctx.isNavVisible;
|
|
15
|
+
const isDefaultLocaleOnlyPath = ctx.isDefaultLocaleOnlyPath;
|
|
16
|
+
const stableDocs = ctx.stableDocs;
|
|
18
17
|
const mergedCategoryMetaCache = /* @__PURE__ */ new Map();
|
|
19
18
|
function stableMergeCategoryMeta(baseDir, localeDir) {
|
|
20
19
|
const key = `${baseDir}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RouteContext, RouteContextPayload } from "../factory-context/index.js";
|
|
2
|
+
import type { Settings } from "../settings.js";
|
|
3
|
+
import type { DocPageEntry } from "../doc-page-props/index.js";
|
|
4
|
+
export type { RouteContext, RouteContextPayload, TagInfo, } from "../factory-context/index.js";
|
|
5
|
+
/** A content-bridge handle: identity-stable, draft-filtered docs loader. */
|
|
6
|
+
export type ContentBridge = (collectionName: string) => DocPageEntry[];
|
|
7
|
+
export interface CreateRouteContextOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The content-bridge handle (`stableDocs`). Default: the package
|
|
10
|
+
* `stableDocs` from `routes/_docs-helpers` (reads `@takazudo/zfb/content`,
|
|
11
|
+
* snapshot-anchored for per-build identity stability). The host may inject
|
|
12
|
+
* its own content loader here.
|
|
13
|
+
*/
|
|
14
|
+
stableDocs?: ContentBridge;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reconstruct the full runtime route context from the serializable payload.
|
|
18
|
+
* Called ONCE per build (the route entrypoints share the returned singleton via
|
|
19
|
+
* the `routes/_context.ts` module), so the memoized closures inside
|
|
20
|
+
* (`createNavSourceDocs` / `createDocRouteEntries` / `createRouteEnumerators`)
|
|
21
|
+
* and the snapshot-anchored `stableDocs` keep array identity stable across all
|
|
22
|
+
* routes.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createRouteContext<S extends Settings = Settings>(payload: RouteContextPayload<S>, options?: CreateRouteContextOptions): RouteContext<S>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { makeUrlHelpers } from "../url-helpers/index.js";
|
|
2
|
+
import { loadCategoryMeta } from "../sidebar-tree/index.js";
|
|
3
|
+
import { extractHeadings as extractHeadingsBase } from "../extract-headings/index.js";
|
|
4
|
+
import { toRouteSlug, toSlugParams } from "../slug/index.js";
|
|
5
|
+
import { resolveTag } from "../tag-helpers/index.js";
|
|
6
|
+
import {
|
|
7
|
+
getCategoryOrder as getCategoryOrderBase,
|
|
8
|
+
getNavSectionForSlug as getNavSectionForSlugBase,
|
|
9
|
+
getNavSubtree as getNavSubtreeBase
|
|
10
|
+
} from "../nav-scope/index.js";
|
|
11
|
+
import { mergeLocaleDocs } from "../locale-merge/index.js";
|
|
12
|
+
import {
|
|
13
|
+
createNavSourceDocs
|
|
14
|
+
} from "../nav-source-docs/index.js";
|
|
15
|
+
import {
|
|
16
|
+
createDocRouteEntries
|
|
17
|
+
} from "../doc-route-entries/index.js";
|
|
18
|
+
import {
|
|
19
|
+
createRouteEnumerators
|
|
20
|
+
} from "../route-enumerators/index.js";
|
|
21
|
+
import {
|
|
22
|
+
stableDocs as defaultStableDocs,
|
|
23
|
+
isNavVisible,
|
|
24
|
+
buildNavTree,
|
|
25
|
+
buildBreadcrumbs,
|
|
26
|
+
collectAutoIndexNodes,
|
|
27
|
+
groupSatelliteNodes,
|
|
28
|
+
findNode,
|
|
29
|
+
firstRoutedHref
|
|
30
|
+
} from "../routes/_docs-helpers.js";
|
|
31
|
+
function createRouteContext(payload, options = {}) {
|
|
32
|
+
const settings = payload.settings;
|
|
33
|
+
const translations = payload.translations;
|
|
34
|
+
const tagVocabulary = payload.tagVocabulary;
|
|
35
|
+
const colorSchemes = payload.colorSchemes;
|
|
36
|
+
const stableDocs = options.stableDocs ?? defaultStableDocs;
|
|
37
|
+
const defaultLocale = settings.defaultLocale;
|
|
38
|
+
const locales = [
|
|
39
|
+
defaultLocale,
|
|
40
|
+
...Object.keys(settings.locales)
|
|
41
|
+
];
|
|
42
|
+
function getLocaleConfig(locale) {
|
|
43
|
+
return settings.locales[locale];
|
|
44
|
+
}
|
|
45
|
+
function getLocaleLabel(locale) {
|
|
46
|
+
if (locale === defaultLocale) return defaultLocale.toUpperCase();
|
|
47
|
+
return getLocaleConfig(locale)?.label ?? locale.toUpperCase();
|
|
48
|
+
}
|
|
49
|
+
function t(key, locale = defaultLocale) {
|
|
50
|
+
return translations[locale]?.[key] ?? translations[defaultLocale]?.[key] ?? key;
|
|
51
|
+
}
|
|
52
|
+
const i18n = { defaultLocale, locales, getLocaleLabel, t };
|
|
53
|
+
const urlHelpers = makeUrlHelpers(settings, i18n);
|
|
54
|
+
const { withBase, docsUrl, versionedDocsUrl, navHref, isDefaultLocaleOnlyPath } = urlHelpers;
|
|
55
|
+
function getCategoryOrder() {
|
|
56
|
+
return getCategoryOrderBase(settings.headerNav);
|
|
57
|
+
}
|
|
58
|
+
function getNavSectionForSlug(slug) {
|
|
59
|
+
return getNavSectionForSlugBase(slug, settings.headerNav);
|
|
60
|
+
}
|
|
61
|
+
function getNavSubtree(tree, categoryMatch) {
|
|
62
|
+
return getNavSubtreeBase(tree, categoryMatch, settings.headerNav);
|
|
63
|
+
}
|
|
64
|
+
function extractHeadings(body) {
|
|
65
|
+
return extractHeadingsBase(body, {
|
|
66
|
+
tocMinDepth: settings.tocMinDepth,
|
|
67
|
+
tocMaxDepth: settings.tocMaxDepth,
|
|
68
|
+
strategy: settings.headingIdStrategy
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function getVocab() {
|
|
72
|
+
return settings.tagVocabulary ? tagVocabulary : false;
|
|
73
|
+
}
|
|
74
|
+
function resolveTagBound(raw) {
|
|
75
|
+
return resolveTag(raw, getVocab(), settings.tagGovernance);
|
|
76
|
+
}
|
|
77
|
+
function collectTags(entries, slugFn) {
|
|
78
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
const rawTags = entry.data.tags ?? [];
|
|
81
|
+
const slug = slugFn(entry.id, entry.data);
|
|
82
|
+
const seen = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const raw of rawTags) {
|
|
84
|
+
const resolved = resolveTagBound(raw);
|
|
85
|
+
if (resolved.deprecated) continue;
|
|
86
|
+
if (seen.has(resolved.canonical)) continue;
|
|
87
|
+
seen.add(resolved.canonical);
|
|
88
|
+
if (!tagMap.has(resolved.canonical)) {
|
|
89
|
+
tagMap.set(resolved.canonical, {
|
|
90
|
+
tag: resolved.canonical,
|
|
91
|
+
count: 0,
|
|
92
|
+
docs: []
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const info = tagMap.get(resolved.canonical);
|
|
96
|
+
info.count++;
|
|
97
|
+
info.docs.push({
|
|
98
|
+
slug,
|
|
99
|
+
title: entry.data.title ?? "",
|
|
100
|
+
description: entry.data.description
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return tagMap;
|
|
105
|
+
}
|
|
106
|
+
const base = {
|
|
107
|
+
settings,
|
|
108
|
+
colorSchemes,
|
|
109
|
+
i18n,
|
|
110
|
+
defaultLocale,
|
|
111
|
+
locales,
|
|
112
|
+
getLocaleConfig,
|
|
113
|
+
getLocaleLabel,
|
|
114
|
+
t,
|
|
115
|
+
urlHelpers,
|
|
116
|
+
...urlHelpers,
|
|
117
|
+
getCategoryOrder,
|
|
118
|
+
getNavSectionForSlug,
|
|
119
|
+
getNavSubtree,
|
|
120
|
+
extractHeadings,
|
|
121
|
+
resolveTagBound,
|
|
122
|
+
collectTags,
|
|
123
|
+
buildNavTree,
|
|
124
|
+
groupSatelliteNodes,
|
|
125
|
+
findNode,
|
|
126
|
+
firstRoutedHref,
|
|
127
|
+
collectAutoIndexNodes,
|
|
128
|
+
isNavVisible,
|
|
129
|
+
stableDocs,
|
|
130
|
+
toRouteSlug,
|
|
131
|
+
toSlugParams
|
|
132
|
+
};
|
|
133
|
+
const navSourceDocs = createNavSourceDocs(base);
|
|
134
|
+
const docRouteEntries = createDocRouteEntries(base);
|
|
135
|
+
const baseWithNav = { ...base, ...navSourceDocs };
|
|
136
|
+
const routeEnumerators = createRouteEnumerators(
|
|
137
|
+
baseWithNav
|
|
138
|
+
);
|
|
139
|
+
return {
|
|
140
|
+
...baseWithNav,
|
|
141
|
+
...docRouteEntries,
|
|
142
|
+
...routeEnumerators
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
createRouteContext
|
|
147
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { NavSourceDocs } from "../nav-source-docs/index.js";
|
|
2
2
|
import type { DocPageEntry, DocNavNode } from "../doc-page-props/index.js";
|
|
3
|
+
import type { CategoryMeta } from "../sidebar-tree/index.js";
|
|
4
|
+
import type { Settings } from "../settings.js";
|
|
3
5
|
export type { DocPageEntry, DocNavNode, NavSourceDocs };
|
|
4
6
|
/**
|
|
5
7
|
* Minimal docs entry shape needed for tag enumeration (no Content/module_specifier).
|
|
@@ -33,100 +35,49 @@ export interface TagInfoForEnum {
|
|
|
33
35
|
count: number;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* Context slice `createRouteEnumerators` derives its bag from (epic Collapse
|
|
39
|
+
* Wiring Shells #2420, FACTORIES #2424 — breaking signature). STRUCTURAL SUBSET
|
|
40
|
+
* of the unified `RouteContext`/`ChromeContext`: `getLocaleKeys`/`getVersions`/
|
|
41
|
+
* `getDocTags` read off `settings`, `loadDocs` is the content-bridge `stableDocs`,
|
|
42
|
+
* `mergeLocaleDocs` is imported directly, and the rest are reconstructed
|
|
43
|
+
* callables already on the context (including the nav-source resolvers, which
|
|
44
|
+
* `createRouteContext` assembles BEFORE the enumerators).
|
|
40
45
|
*/
|
|
41
46
|
export interface RouteEnumeratorsContext {
|
|
42
|
-
/**
|
|
47
|
+
/** The host's resolved settings object (reads `locales`/`versions`/`docTags`). */
|
|
48
|
+
settings: Settings;
|
|
49
|
+
/** Default locale code. */
|
|
43
50
|
defaultLocale: string;
|
|
44
|
-
/**
|
|
45
|
-
* Getter for all non-default locale codes.
|
|
46
|
-
* Host passes `() => Object.keys(settings.locales)`.
|
|
47
|
-
* Called per invocation so mutations to settings.locales are picked up.
|
|
48
|
-
*/
|
|
49
|
-
getLocaleKeys: () => readonly string[];
|
|
50
|
-
/**
|
|
51
|
-
* Getter for the configured versions list (or false/undefined).
|
|
52
|
-
* Host passes `() => settings.versions`.
|
|
53
|
-
* Called per invocation so mutations to settings.versions are picked up.
|
|
54
|
-
*/
|
|
55
|
-
getVersions: () => VersionConfigForEnum[] | false | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Getter for whether tag pages are enabled.
|
|
58
|
-
* Host passes `() => settings.docTags`.
|
|
59
|
-
*/
|
|
60
|
-
getDocTags: () => boolean | undefined;
|
|
61
|
-
/** `docsUrl(slug, lang)` from `@/utils/base` (resolved with settings). */
|
|
51
|
+
/** Build a docs URL for the given slug and locale. */
|
|
62
52
|
docsUrl: (slug: string, lang?: string) => string;
|
|
63
|
-
/**
|
|
53
|
+
/** Build a versioned docs URL. */
|
|
64
54
|
versionedDocsUrl: (slug: string, versionSlug: string, lang?: string) => string;
|
|
65
|
-
/**
|
|
55
|
+
/** Prefix a path with the configured base directory. */
|
|
66
56
|
withBase: (path: string) => string;
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*/
|
|
71
|
-
loadDocs: (collectionName: string) => DocsEntryForTags[];
|
|
72
|
-
/**
|
|
73
|
-
* Returns true for paths that are only shown in the default locale.
|
|
74
|
-
* Host passes `isDefaultLocaleOnlyPath` from `@/utils/base`.
|
|
75
|
-
*/
|
|
57
|
+
/** Identity-stable, draft-filtered docs array for a collection. */
|
|
58
|
+
stableDocs: (collectionName: string) => DocPageEntry[];
|
|
59
|
+
/** Returns true for paths that are only shown in the default locale. */
|
|
76
60
|
isDefaultLocaleOnlyPath: (path: string) => boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Collect tags from a docs array.
|
|
79
|
-
* Host passes `collectTags` from `@/utils/tags`.
|
|
80
|
-
*/
|
|
61
|
+
/** Aggregate a `tag → docs` index from a doc collection. */
|
|
81
62
|
collectTags: (docs: DocsEntryForTags[], slugFn: (id: string, data: {
|
|
82
63
|
slug?: string;
|
|
83
64
|
}) => string) => Map<string, TagInfoForEnum>;
|
|
84
|
-
/**
|
|
85
|
-
* Convert a content entry slug to a canonical route slug.
|
|
86
|
-
* Host passes `toRouteSlug` from `@/utils/slug`.
|
|
87
|
-
*/
|
|
65
|
+
/** Convert a content entry slug to a canonical route slug. */
|
|
88
66
|
toRouteSlug: (id: string) => string;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*/
|
|
93
|
-
buildNavTree: (docs: DocPageEntry[], locale: string, categoryMeta: Map<string, unknown>) => DocNavNode[];
|
|
94
|
-
/**
|
|
95
|
-
* Collect auto-generated index nodes.
|
|
96
|
-
* Host passes `collectAutoIndexNodes` from `@/utils/docs`.
|
|
97
|
-
*/
|
|
67
|
+
/** Build the nav tree for a locale (4-arg form with an explicit href builder). */
|
|
68
|
+
buildNavTree: (docs: DocPageEntry[], locale: string, categoryMeta: Map<string, CategoryMeta> | undefined, buildHref: (slug: string, locale: string) => string) => DocNavNode[];
|
|
69
|
+
/** Collect auto-generated index nodes. */
|
|
98
70
|
collectAutoIndexNodes: (tree: DocNavNode[]) => DocNavNode[];
|
|
99
|
-
/**
|
|
100
|
-
* Resolve the identity-stable nav source for an EN/locale context.
|
|
101
|
-
* Host passes `resolveNavSource` from `pages/lib/_nav-source-docs.ts`.
|
|
102
|
-
*/
|
|
71
|
+
/** Resolve the identity-stable nav source for an EN/locale context. */
|
|
103
72
|
resolveNavSource: (lang: string, currentVersion: string | undefined, options?: {
|
|
104
73
|
applyDefaultLocaleOnlyFilter?: boolean;
|
|
105
74
|
keepUnlisted?: boolean;
|
|
106
75
|
}) => NavSourceDocs;
|
|
107
|
-
/**
|
|
108
|
-
* Resolve the identity-stable nav source for a versioned non-default-locale
|
|
109
|
-
* context.
|
|
110
|
-
* Host passes `resolveVersionedLocaleSource` from `pages/lib/_nav-source-docs.ts`.
|
|
111
|
-
*/
|
|
76
|
+
/** Resolve the identity-stable nav source for a versioned non-default-locale context. */
|
|
112
77
|
resolveVersionedLocaleSource: (versionSlug: string, versionDocsDir: string | undefined, lang: string, localeDir: string | undefined, options?: {
|
|
113
78
|
applyDefaultLocaleOnlyFilter?: boolean;
|
|
114
79
|
keepUnlisted?: boolean;
|
|
115
80
|
}) => NavSourceDocs;
|
|
116
|
-
/**
|
|
117
|
-
* Merge locale docs with base-locale fallbacks.
|
|
118
|
-
* Host passes `mergeLocaleDocs` from `pages/lib/locale-merge.ts`.
|
|
119
|
-
*/
|
|
120
|
-
mergeLocaleDocs: (options: {
|
|
121
|
-
baseDocs: DocsEntryForTags[];
|
|
122
|
-
localeDocs: DocsEntryForTags[];
|
|
123
|
-
applyDefaultLocaleOnlyFilter?: boolean;
|
|
124
|
-
keepUnlisted?: boolean;
|
|
125
|
-
isDefaultLocaleOnlyPath?: (path: string) => boolean;
|
|
126
|
-
}) => {
|
|
127
|
-
docs: DocsEntryForTags[];
|
|
128
|
-
localeSlugSet: ReadonlySet<string>;
|
|
129
|
-
};
|
|
130
81
|
}
|
|
131
82
|
export interface RouteEnumeratorsAPI {
|
|
132
83
|
/**
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
+
import { mergeLocaleDocs as mergeLocaleDocsImpl } from "../locale-merge/index.js";
|
|
1
2
|
function createRouteEnumerators(ctx) {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
mergeLocaleDocs
|
|
19
|
-
} = ctx;
|
|
3
|
+
const defaultLocale = ctx.defaultLocale;
|
|
4
|
+
const getLocaleKeys = () => Object.keys(ctx.settings.locales);
|
|
5
|
+
const getVersions = () => ctx.settings.versions;
|
|
6
|
+
const getDocTags = () => ctx.settings.docTags;
|
|
7
|
+
const docsUrl = ctx.docsUrl;
|
|
8
|
+
const versionedDocsUrl = ctx.versionedDocsUrl;
|
|
9
|
+
const withBase = ctx.withBase;
|
|
10
|
+
const loadDocs = (collectionName) => ctx.stableDocs(collectionName);
|
|
11
|
+
const isDefaultLocaleOnlyPath = ctx.isDefaultLocaleOnlyPath;
|
|
12
|
+
const collectTags = ctx.collectTags;
|
|
13
|
+
const toRouteSlug = ctx.toRouteSlug;
|
|
14
|
+
const buildNavTree = (docs, locale, categoryMeta) => ctx.buildNavTree(docs, locale, categoryMeta, (slug, loc) => ctx.docsUrl(slug, loc));
|
|
15
|
+
const collectAutoIndexNodes = ctx.collectAutoIndexNodes;
|
|
16
|
+
const resolveNavSource = ctx.resolveNavSource;
|
|
17
|
+
const resolveVersionedLocaleSource = ctx.resolveVersionedLocaleSource;
|
|
18
|
+
const mergeLocaleDocs = mergeLocaleDocsImpl;
|
|
20
19
|
function enumerateDocsRoutes(locale) {
|
|
21
20
|
const urls = [];
|
|
22
21
|
const { docs: allDocs, navDocs, categoryMeta } = resolveNavSource(
|
package/dist/routes/_chrome.d.ts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
/** @jsxRuntime automatic */
|
|
2
|
-
/** @jsxImportSource preact */
|
|
3
|
-
import type { JSX, VNode, ComponentChildren } from "preact";
|
|
4
1
|
import type { DocNavNode } from "./_docs-helpers.js";
|
|
5
|
-
|
|
6
|
-
* `BodyEndIslands` (AiChatModal / ImageEnlarge / MermaidEnlarge), reconstructed
|
|
7
|
-
* from the serializable virtual-module `settings` flags (#2406 / #2401(c)).
|
|
8
|
-
* The host-owned bootstraps (client-router / design-token-panel) cannot live
|
|
9
|
-
* in the package, so they are NOT included here — A2/S4 re-homes those. */
|
|
10
|
-
declare const BodyEndIslands: (props: import("../doc-body-end-islands/index.js").BodyEndIslandsProps) => JSX.Element;
|
|
11
|
-
export declare const composeMetaTitle: (title: string) => string;
|
|
12
|
-
export declare const HeadWithDefaults: (props: import("../head-with-defaults/index.js").HeadWithDefaultsProps) => JSX.Element;
|
|
13
|
-
export declare const HeaderWithDefaults: (props: import("../header-with-defaults/index.js").HeaderWithDefaultsProps) => JSX.Element;
|
|
14
|
-
export declare const FooterWithDefaults: (props: {
|
|
2
|
+
export declare const composeMetaTitle: (title: string) => string, HeadWithDefaults: (props: import("../head-with-defaults/index.js").HeadWithDefaultsProps) => import("preact").JSX.Element, HeaderWithDefaults: (props: import("../header-with-defaults/index.js").HeaderWithDefaultsProps) => import("preact").JSX.Element, FooterWithDefaults: (props: {
|
|
15
3
|
lang?: string;
|
|
16
|
-
}) => VNode
|
|
17
|
-
export declare const SidebarWithDefaults: (props: import("../sidebar-with-defaults/index.js").SidebarWithDefaultsProps) => JSX.Element;
|
|
18
|
-
declare const SiteTreeNavWrapper: (props: import("../site-tree-nav/index.js").SiteTreeNavWrapperProps) => JSX.Element | null;
|
|
19
|
-
export declare function createMdxComponentsBound(lang?: string): Record<string, unknown>;
|
|
20
|
-
export declare const renderDocPage: (props: import("../doc-page-props/index.js").DocPageBaseProps, opts: import("../doc-page-renderer/index.js").RenderDocPageOptions) => JSX.Element;
|
|
21
|
-
export declare const VersionsPageView: (props: import("../versions-page/index.js").VersionsPageViewProps) => JSX.Element;
|
|
22
|
-
export declare const collectTagMapForLocale: (locale: string) => Map<string, import("../tag-pages/index.js").TagInfo>, TagDetailPageView: (props: {
|
|
4
|
+
}) => import("preact").VNode, SidebarWithDefaults: (props: import("../sidebar-with-defaults/index.js").SidebarWithDefaultsProps) => import("preact").JSX.Element, renderDocPage: (props: import("../doc-page-props/index.js").DocPageBaseProps, opts: import("../doc-page-renderer/index.js").RenderDocPageOptions) => import("preact").JSX.Element, VersionsPageView: (props: import("../versions-page/index.js").VersionsPageViewProps) => import("preact").JSX.Element, collectTagMapForLocale: (locale: string) => Map<string, import("../tag-pages/index.js").TagInfo>, TagDetailPageView: (props: {
|
|
23
5
|
locale: string;
|
|
24
6
|
tag: string;
|
|
25
7
|
tagInfo: import("../tag-pages/index.js").TagInfo;
|
|
26
|
-
}) => JSX.Element, TagsIndexPageView: (props: {
|
|
8
|
+
}) => import("preact").JSX.Element, TagsIndexPageView: (props: {
|
|
27
9
|
locale: string;
|
|
28
|
-
children?: ComponentChildren;
|
|
29
|
-
}) => JSX.Element;
|
|
30
|
-
export {
|
|
31
|
-
export { buildDocRouteEntries, } from "./_context.js";
|
|
10
|
+
children?: import("preact").ComponentChildren;
|
|
11
|
+
}) => import("preact").JSX.Element, SiteTreeNavWrapper: import("../factory-context/index.js").FactoryComponent, BodyEndIslands: (props: import("../doc-body-end-islands/index.js").BodyEndIslandsProps) => import("preact").JSX.Element;
|
|
12
|
+
export { buildDocRouteEntries } from "./_context.js";
|
|
32
13
|
export type { DocNavNode };
|