create-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/scaffold.d.ts +1 -1
- package/dist/scaffold.js +2 -2
- package/package.json +1 -1
- package/templates/base/pages/index.tsx +6 -4
- package/templates/base/pages/lib/_chrome.ts +166 -0
- package/templates/base/pages/lib/_doc-route-entries.ts +7 -51
- package/templates/base/pages/lib/_nav-source-docs.ts +9 -29
- package/templates/base/pages/lib/_route-context.ts +32 -0
- package/templates/base/src/config/tag-vocabulary-types.ts +4 -39
- package/templates/features/i18n/files/pages/[locale]/index.tsx +6 -4
- package/templates/base/pages/_mdx-components.ts +0 -106
- package/templates/base/pages/lib/_category-nav.tsx +0 -34
- package/templates/base/pages/lib/_category-tree-nav.tsx +0 -45
- package/templates/base/pages/lib/_compose-meta-title.ts +0 -25
- package/templates/base/pages/lib/_doc-body-end.tsx +0 -8
- package/templates/base/pages/lib/_doc-content-header.tsx +0 -17
- package/templates/base/pages/lib/_doc-history-area.tsx +0 -34
- package/templates/base/pages/lib/_doc-metainfo-area.tsx +0 -26
- package/templates/base/pages/lib/_doc-page-renderer.tsx +0 -31
- package/templates/base/pages/lib/_doc-page-shell.tsx +0 -29
- package/templates/base/pages/lib/_doc-pager.tsx +0 -9
- package/templates/base/pages/lib/_doc-route-paths.ts +0 -16
- package/templates/base/pages/lib/_doc-tags-area.tsx +0 -30
- package/templates/base/pages/lib/_footer-with-defaults.tsx +0 -58
- package/templates/base/pages/lib/_head-with-defaults.tsx +0 -22
- package/templates/base/pages/lib/_header-with-defaults.tsx +0 -45
- package/templates/base/pages/lib/_inline-version-switcher.tsx +0 -23
- package/templates/base/pages/lib/_math-block.tsx +0 -4
- package/templates/base/pages/lib/_nav-data-prep.ts +0 -118
- package/templates/base/pages/lib/_search-widget-script.ts +0 -2
- package/templates/base/pages/lib/_sidebar-prepaint.tsx +0 -11
- package/templates/base/pages/lib/_sidebar-with-defaults.tsx +0 -26
- package/templates/base/pages/lib/_site-tree-nav.tsx +0 -37
- package/templates/base/pages/lib/_toc-title.ts +0 -3
- package/templates/base/pages/lib/route-enumerators.ts +0 -58
- package/templates/base/src/components/tree-nav-shared.tsx +0 -71
- package/templates/base/src/utils/content-files.ts +0 -110
- package/templates/features/docTags/files/pages/lib/_tag-pages.tsx +0 -47
- package/templates/features/versioning/files/pages/lib/_versions-page.tsx +0 -33
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Shared constants and primitives for sidebar-tree and site-tree-nav
|
|
2
|
-
|
|
3
|
-
// Indentation — fluid clamp values
|
|
4
|
-
export const INDENT = "clamp(0.8rem, 1.2vw, 1.625rem)";
|
|
5
|
-
export const CONNECTOR_OFFSET = "clamp(0.2rem, 0.3vw, 0.5rem)";
|
|
6
|
-
export const CONNECTOR_WIDTH = "clamp(0.4rem, 0.6vw, 1rem)";
|
|
7
|
-
export const BASE_PAD = "clamp(0.4rem, 0.8vw, 1.3rem)";
|
|
8
|
-
|
|
9
|
-
export function connectorLeft(depth: number): string {
|
|
10
|
-
return `calc(${depth} * ${INDENT} + ${CONNECTOR_OFFSET})`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const CATEGORY_LINK_PATH =
|
|
14
|
-
"M5.746 5.74 0 11.49l20.987 20.96C34.126 45.572 41.963 53.45 41.948 53.523c-.012.062-9.456 9.544-20.986 21.07L0 95.55l5.714 5.715c3.142 3.143 5.748 5.715 5.79 5.715s2.63-2.563 5.75-5.696l17.939-18.001c21.867-21.94 29.443-29.599 29.443-29.768 0-.114-.665-.804-5.084-5.275C51.872 40.47 11.71.125 11.565.036 11.525.01 8.906 2.578 5.746 5.74m38.345-.066c-3.132 3.13-5.696 5.71-5.696 5.732-.001.022 2.16 2.185 4.8 4.807 2.641 2.623 8.382 8.338 12.758 12.702 15.38 15.337 23.763 23.641 24.314 24.086.19.153.346.336.346.405 0 .07-1.738 1.847-3.887 3.976a17515 17515 0 0 0-20.35 20.264 19555 19555 0 0 1-17.223 17.158c-.416.409-.757.77-.757.8 0 .083 11.415 11.485 11.457 11.445.235-.22 53.542-53.528 53.542-53.543C103.395 53.472 49.891.02 49.837 0c-.028-.01-2.613 2.543-5.746 5.674";
|
|
15
|
-
|
|
16
|
-
export function CategoryLinkIcon({ className }: { className?: string }) {
|
|
17
|
-
return (
|
|
18
|
-
<svg
|
|
19
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
20
|
-
fill="currentColor"
|
|
21
|
-
viewBox="0 0 103.395 107.049"
|
|
22
|
-
aria-hidden="true"
|
|
23
|
-
className={`shrink-0 ${className ?? ""}`}
|
|
24
|
-
>
|
|
25
|
-
<path d={CATEGORY_LINK_PATH} />
|
|
26
|
-
</svg>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function ConnectorLines({
|
|
31
|
-
depth,
|
|
32
|
-
isLast,
|
|
33
|
-
widthScale = 1,
|
|
34
|
-
topPad = "0px",
|
|
35
|
-
}: {
|
|
36
|
-
depth: number;
|
|
37
|
-
isLast: boolean;
|
|
38
|
-
widthScale?: number;
|
|
39
|
-
/**
|
|
40
|
-
* Padding-top of the inner content row that holds the link text. The horizontal
|
|
41
|
-
* connector and (when `isLast`) the vertical clip both anchor to the first-line
|
|
42
|
-
* midpoint computed as `topPad + 0.5lh`, so multi-line labels keep the connector
|
|
43
|
-
* aligned with the first line instead of the row's vertical center.
|
|
44
|
-
*/
|
|
45
|
-
topPad?: string;
|
|
46
|
-
}) {
|
|
47
|
-
if (depth === 0) return null;
|
|
48
|
-
const left = connectorLeft(depth);
|
|
49
|
-
const width = widthScale === 1 ? CONNECTOR_WIDTH : `calc(${CONNECTOR_WIDTH} * ${widthScale})`;
|
|
50
|
-
const firstLineMid = `calc(${topPad} + 0.5lh)`;
|
|
51
|
-
return (
|
|
52
|
-
<>
|
|
53
|
-
<div
|
|
54
|
-
className="absolute border-l border-dashed border-muted"
|
|
55
|
-
style={{
|
|
56
|
-
left,
|
|
57
|
-
top: 0,
|
|
58
|
-
bottom: isLast ? `calc(100% - ${firstLineMid})` : 0,
|
|
59
|
-
}}
|
|
60
|
-
/>
|
|
61
|
-
<div
|
|
62
|
-
className="absolute border-t border-dashed border-muted"
|
|
63
|
-
style={{
|
|
64
|
-
left,
|
|
65
|
-
width,
|
|
66
|
-
top: firstLineMid,
|
|
67
|
-
}}
|
|
68
|
-
/>
|
|
69
|
-
</>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { readFileSync, readdirSync } from "node:fs";
|
|
2
|
-
import { join, relative } from "node:path";
|
|
3
|
-
import matter from "gray-matter";
|
|
4
|
-
import { settings } from "../config/settings";
|
|
5
|
-
|
|
6
|
-
/** Strip markdown formatting to produce plain text */
|
|
7
|
-
export function stripMarkdown(md: string): string {
|
|
8
|
-
return (
|
|
9
|
-
md
|
|
10
|
-
// Remove code blocks
|
|
11
|
-
.replace(/```[\s\S]*?```/g, "")
|
|
12
|
-
.replace(/`[^`]+`/g, "")
|
|
13
|
-
// Remove HTML tags
|
|
14
|
-
.replace(/<[^>]+>/g, "")
|
|
15
|
-
// Remove headings markers
|
|
16
|
-
.replace(/^#{1,6}\s+/gm, "")
|
|
17
|
-
// Remove emphasis/bold markers
|
|
18
|
-
.replace(/\*{1,3}([^*]+)\*{1,3}/g, "$1")
|
|
19
|
-
.replace(/_{1,3}([^_]+)_{1,3}/g, "$1")
|
|
20
|
-
// Remove images (must run before link removal)
|
|
21
|
-
.replace(/!\[[^\]]*\]\([^)]+\)/g, "")
|
|
22
|
-
// Remove links but keep text
|
|
23
|
-
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
|
|
24
|
-
// Remove blockquote markers
|
|
25
|
-
.replace(/^>\s+/gm, "")
|
|
26
|
-
// Remove horizontal rules
|
|
27
|
-
.replace(/^[-*_]{3,}\s*$/gm, "")
|
|
28
|
-
// Remove list markers
|
|
29
|
-
.replace(/^[\s]*[-*+]\s+/gm, "")
|
|
30
|
-
.replace(/^[\s]*\d+\.\s+/gm, "")
|
|
31
|
-
// Remove import statements
|
|
32
|
-
.replace(/^import\s+.*$/gm, "")
|
|
33
|
-
// Remove export statements
|
|
34
|
-
.replace(/^export\s+.*$/gm, "")
|
|
35
|
-
// Collapse whitespace
|
|
36
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
37
|
-
.trim()
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Walk a directory and collect all .md/.mdx files */
|
|
42
|
-
export function collectMdFiles(
|
|
43
|
-
dir: string,
|
|
44
|
-
): Array<{ filePath: string; slug: string }> {
|
|
45
|
-
const results: Array<{ filePath: string; slug: string }> = [];
|
|
46
|
-
|
|
47
|
-
function walk(currentDir: string, baseDir: string): void {
|
|
48
|
-
let entries;
|
|
49
|
-
try {
|
|
50
|
-
entries = readdirSync(currentDir, { withFileTypes: true });
|
|
51
|
-
} catch {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
for (const entry of entries) {
|
|
55
|
-
const fullPath = join(currentDir, entry.name);
|
|
56
|
-
if (entry.isDirectory()) {
|
|
57
|
-
// Skip `_`-prefixed dirs to match the Content Collections convention
|
|
58
|
-
// (and zfb's routing): docs under them are not built as pages, so
|
|
59
|
-
// indexing them would yield search results whose links 404.
|
|
60
|
-
if (entry.name.startsWith("_")) continue;
|
|
61
|
-
walk(fullPath, baseDir);
|
|
62
|
-
} else if (/\.mdx?$/.test(entry.name) && !entry.name.startsWith("_")) {
|
|
63
|
-
const rel = relative(baseDir, fullPath)
|
|
64
|
-
.replace(/\.mdx?$/, "")
|
|
65
|
-
.replace(/\/index$/, "");
|
|
66
|
-
results.push({ filePath: fullPath, slug: rel });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
walk(dir, dir);
|
|
72
|
-
return results;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Compute a URL from a slug and locale. When absolute is true and siteUrl is configured, returns a full URL. */
|
|
76
|
-
export function slugToUrl(slug: string, locale: string | null, absolute = false): string {
|
|
77
|
-
const base = settings.base.replace(/\/$/, "");
|
|
78
|
-
const path = locale ? `${base}/${locale}/docs/${slug}` : `${base}/docs/${slug}`;
|
|
79
|
-
if (absolute && settings.siteUrl) {
|
|
80
|
-
return `${settings.siteUrl.replace(/\/$/, "")}${path}`;
|
|
81
|
-
}
|
|
82
|
-
return path;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Frontmatter fields used across the project */
|
|
86
|
-
export interface DocFrontmatter {
|
|
87
|
-
title?: string;
|
|
88
|
-
description?: string;
|
|
89
|
-
sidebar_position?: number;
|
|
90
|
-
category?: string;
|
|
91
|
-
draft?: boolean;
|
|
92
|
-
unlisted?: boolean;
|
|
93
|
-
search_exclude?: boolean;
|
|
94
|
-
[key: string]: unknown;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** Parse a markdown file and return frontmatter + content */
|
|
98
|
-
export function parseMarkdownFile(filePath: string): { data: DocFrontmatter; content: string } | null {
|
|
99
|
-
try {
|
|
100
|
-
const raw = readFileSync(filePath, "utf-8");
|
|
101
|
-
return matter(raw);
|
|
102
|
-
} catch {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** Check if a document should be excluded from indexing */
|
|
108
|
-
export function isExcluded(data: DocFrontmatter): boolean {
|
|
109
|
-
return !!(data.search_exclude || data.draft || data.unlisted);
|
|
110
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/** @jsxRuntime automatic */
|
|
2
|
-
/** @jsxImportSource preact */
|
|
3
|
-
// Thin stub — tag-pages moved to the package (epic #2344, S8).
|
|
4
|
-
// Calls `createTagPages(deps)` from @takazudo/zudo-doc/tag-pages with host
|
|
5
|
-
// singletons injected, then re-exports the resulting functions so all existing
|
|
6
|
-
// call sites continue to work unchanged.
|
|
7
|
-
|
|
8
|
-
import { createTagPages } from "@takazudo/zudo-doc/tag-pages";
|
|
9
|
-
import type { TagInfo } from "@takazudo/zudo-doc/tag-pages";
|
|
10
|
-
import { collectTags } from "@/utils/tags";
|
|
11
|
-
import { defaultLocale, t } from "@/config/i18n";
|
|
12
|
-
import { settings } from "@/config/settings";
|
|
13
|
-
import { withBase, docsUrl } from "@/utils/base";
|
|
14
|
-
import { isDefaultLocaleOnlyPath } from "@/utils/base";
|
|
15
|
-
import { FooterWithDefaults } from "./_footer-with-defaults";
|
|
16
|
-
import { HeaderWithDefaults } from "./_header-with-defaults";
|
|
17
|
-
import { HeadWithDefaults } from "./_head-with-defaults";
|
|
18
|
-
import { composeMetaTitle } from "./_compose-meta-title";
|
|
19
|
-
import { DocHistoryArea } from "./_doc-history-area";
|
|
20
|
-
import { BodyEndIslands } from "./_body-end-islands";
|
|
21
|
-
import { stableDocs } from "./_nav-source-cache";
|
|
22
|
-
|
|
23
|
-
export type { TagInfo };
|
|
24
|
-
|
|
25
|
-
const { collectTagMapForLocale, TagDetailPageView, TagsIndexPageView } = createTagPages({
|
|
26
|
-
settings,
|
|
27
|
-
defaultLocale,
|
|
28
|
-
t,
|
|
29
|
-
withBase,
|
|
30
|
-
docsUrl,
|
|
31
|
-
composeMetaTitle,
|
|
32
|
-
collectTags: collectTags as (
|
|
33
|
-
entries: import("@takazudo/zudo-doc/tag-pages").TagPagesDocsEntry[],
|
|
34
|
-
slugFn: (id: string, data: { slug?: string }) => string,
|
|
35
|
-
) => Map<string, TagInfo>,
|
|
36
|
-
stableDocs: stableDocs as (collectionName: string) => import("@takazudo/zudo-doc/tag-pages").TagPagesDocsEntry[],
|
|
37
|
-
isDefaultLocaleOnlyPath,
|
|
38
|
-
components: {
|
|
39
|
-
HeadWithDefaults,
|
|
40
|
-
HeaderWithDefaults,
|
|
41
|
-
FooterWithDefaults,
|
|
42
|
-
BodyEndIslands,
|
|
43
|
-
DocHistoryArea,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export { collectTagMapForLocale, TagDetailPageView, TagsIndexPageView };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** @jsxRuntime automatic */
|
|
2
|
-
/** @jsxImportSource preact */
|
|
3
|
-
// Thin stub — versions-page moved to the package (epic #2344, S8).
|
|
4
|
-
// Calls `createVersionsPageView(deps)` from
|
|
5
|
-
// @takazudo/zudo-doc/versions-page with host singletons injected,
|
|
6
|
-
// then re-exports the resulting component so all existing call sites continue
|
|
7
|
-
// to work unchanged.
|
|
8
|
-
|
|
9
|
-
import { createVersionsPageView } from "@takazudo/zudo-doc/versions-page";
|
|
10
|
-
import { settings } from "@/config/settings";
|
|
11
|
-
import { defaultLocale, t } from "@/config/i18n";
|
|
12
|
-
import { withBase } from "@/utils/base";
|
|
13
|
-
import { FooterWithDefaults } from "./_footer-with-defaults";
|
|
14
|
-
import { HeaderWithDefaults } from "./_header-with-defaults";
|
|
15
|
-
import { HeadWithDefaults } from "./_head-with-defaults";
|
|
16
|
-
import { composeMetaTitle } from "./_compose-meta-title";
|
|
17
|
-
import { BodyEndIslands } from "./_body-end-islands";
|
|
18
|
-
|
|
19
|
-
export { type VersionsPageViewProps } from "@takazudo/zudo-doc/versions-page";
|
|
20
|
-
|
|
21
|
-
export const VersionsPageView = createVersionsPageView({
|
|
22
|
-
settings,
|
|
23
|
-
defaultLocale,
|
|
24
|
-
t,
|
|
25
|
-
withBase,
|
|
26
|
-
composeMetaTitle,
|
|
27
|
-
components: {
|
|
28
|
-
HeadWithDefaults,
|
|
29
|
-
HeaderWithDefaults,
|
|
30
|
-
FooterWithDefaults,
|
|
31
|
-
BodyEndIslands,
|
|
32
|
-
},
|
|
33
|
-
});
|