docs: move component reference to showcase

This commit is contained in:
2026-07-29 13:31:10 +05:30
parent 19e20408db
commit 5a75e88f73
161 changed files with 17507 additions and 37637 deletions
+40 -25
View File
@@ -23,23 +23,19 @@ const uiReference = existsSync(uiReferencePath)
name: string;
mount: string;
category: string;
purpose: string;
source: string;
props: Array<{ name: string; type: string; required: boolean; default: string | null }>;
slots: string[];
events: string[];
}>;
})
: undefined;
const componentSlug = (name: string) =>
(name === "file-upload" ? "file-upload-primitive" : name)
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
.replace(/[^a-zA-Z0-9]+/g, "-")
.replace(/^-|-$/g, "")
.toLowerCase();
const uiReferenceText = uiReference
? uiReference.components
.map(
(component) =>
`### ${component.name}\nMount: data-component="${component.mount}"\nCategory: ${component.category}\nProps: ${component.props.length ? component.props.map((prop) => `${prop.name}: ${prop.type}${prop.required ? " (required)" : ` = ${prop.default}`}`).join(", ") : "none"}\nSlots: ${component.slots.join(", ") || "none"}\nEvents: ${component.events.join(", ") || "none"}`,
`### ${component.name}\nShowcase: https://component.wrnexusjs.dev/\nMount: <${component.mount} /> (legacy: data-component="${component.mount}")\nCategory: ${component.category}\nPurpose: ${component.purpose}\nProps: ${component.props.length ? component.props.map((prop) => `${prop.name}: ${prop.type}${prop.required ? " (required)" : ` = ${prop.default}`}`).join(", ") : "none"}\nSlots: ${component.slots.join(", ") || "none"}\nEvents: ${component.events.join(", ") || "none"}`,
)
.join("\n\n")
: "UI component reference unavailable; install the release-aligned @wrnexus/ui package.";
@@ -55,7 +51,7 @@ const code = (s: string) =>
const navigation = [
["/getting-started", "Get started"],
["/packages", "Packages"],
["/components", "Components"],
["https://component.wrnexusjs.dev/", "Components"],
["/language", "Language"],
["/architecture", "Architecture"],
] as const;
@@ -126,8 +122,8 @@ function marketingShell(description: string, body: string) {
view {
<SkipLink label="Skip to content" href="#main" class="docs-skip-link" />
<div class="docs-shell marketing-shell">
<header class="topbar marketing-header"><a class="brand" href="/"><span>W</span> WRNexusJS</a><nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav><div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v${version}</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme">◐</button></div></header>
<div class="marketing-mobile-nav"><details><summary>Menu</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/examples">Examples</a></nav></details></div>
<header class="topbar marketing-header"><a class="brand" href="/"><span>W</span> WRNexusJS</a><nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav><div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v${version}</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme">◐</button></div></header>
<div class="marketing-mobile-nav"><details><summary>Menu</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/examples">Examples</a></nav></details></div>
<main id="main" class="marketing-main">${marketingBody}</main>
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS ${version}</strong><span>Build from the server. Ship only what matters.</span></p></div><nav aria-label="Footer"><a href="/getting-started">Documentation</a><a href="/roadmap">Roadmap</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Bun-native · Created by <a href="https://workroot.in/">WorkRoot</a></p></footer>
<BackToTop />
@@ -471,7 +467,6 @@ const routes = [
"/architecture",
"/language",
"/packages",
"/components",
...Object.keys(guides).map((x) => `/guides/${x}`),
"/examples",
"/showcase",
@@ -485,13 +480,7 @@ const routes = [
"/search",
"/404",
].filter(Boolean);
const urls = [
...new Set([
...routes,
...packageNames.map((x) => `/packages/${x}`),
...(uiReference?.components.map((item) => `/components/${componentSlug(item.name)}`) ?? []),
]),
];
const urls = [...new Set([...routes, ...packageNames.map((x) => `/packages/${x}`)])];
writeFileSync(
join(pub, "robots.txt"),
`User-agent: *\nAllow: /\nSitemap: https://wrnexusjs.dev/sitemap.xml\n`,
@@ -523,19 +512,22 @@ await writeFormatted(
2,
),
);
writeFileSync(
join(pub, "llms-full.txt"),
`# WRNexusJS ${version} comprehensive documentation index\n\nStatus: Private Developer Preview. Runtime: Bun. UI language: .wrn.\nThis is the documentation application, not the framework monorepo.\n\n${urls.map((x) => `- https://wrnexusjs.dev${x}`).join("\n")}\n\nFor exact APIs, use installed package README files followed by exported declarations.\n\n# Complete @wrnexus/ui component reference\n\n${uiReferenceText}\n`,
);
const packageMarker = "# Installed package documentation";
const existingGuide = readFileSync(join(pub, "llms.txt"), "utf8");
let frameworkGuide = existingGuide.split(`\n${packageMarker}`)[0]!.trim();
let frameworkGuide = existingGuide
.split(
/\n# (?:Canonical documentation locations|Installed package index|UI component catalog|Installed package documentation)/,
)[0]!
.trim();
if (frameworkGuide.startsWith("# WRNexusJS documentation ")) {
frameworkGuide = frameworkGuide.replace(
/^# WRNexusJS documentation [^\n]+/,
`# WRNexusJS documentation ${version}`,
);
frameworkGuide = frameworkGuide.replace(
/^Status: Private Developer Preview\. This site documents \d+ release-aligned packages\.$/m,
`Status: Private Developer Preview. This site documents ${packageCount} release-aligned packages.`,
);
} else {
frameworkGuide = `# WRNexusJS documentation ${version}\n\nStatus: Private Developer Preview. This site documents ${packageCount} release-aligned packages.\n\n${frameworkGuide}`;
}
@@ -547,9 +539,32 @@ const installedPackageDocs = packageNames
return `## @wrnexus/${name}\n\nDocumentation URL: https://wrnexusjs.dev/packages/${name}\n\n${readme}\n\n### Exported TypeScript declarations\n\n\`\`\`ts\n${declarations}\n\`\`\``;
})
.join("\n\n---\n\n");
const packageIndex = packageNames
.map(
(name) =>
`- @wrnexus/${name} ${version}: https://wrnexusjs.dev/packages/${name} (README and complete exported TypeScript API are included in llms-full.txt)`,
)
.join("\n");
const componentSources =
uiReference?.components
.map((component) => {
const sourcePath = join(root, "node_modules", "@wrnexus", "ui", component.source);
const source = existsSync(sourcePath)
? readFileSync(sourcePath, "utf8").trim()
: "Source unavailable in the installed package.";
return `## ${component.name}\n\n${uiReferenceText
.split(`### ${component.name}\n`)[1]
?.split("\n\n### ")[0]
?.trim()}\n\n### Complete .wrn source contract\n\n\`\`\`wrn\n${source}\n\`\`\``;
})
.join("\n\n---\n\n") ?? "";
writeFileSync(
join(pub, "llms.txt"),
`${frameworkGuide}\n\n# UI component catalog\n\nThe installed @wrnexus/ui release contains ${uiReference?.count ?? 0} documented components. Every mount name, prop type, required/default status, slot, and event is included below and in llms-full.txt.\n\n${uiReferenceText}\n\n${packageMarker}\n\nThe following README files and declarations come from the installed private ${version} release.\n\n${installedPackageDocs}\n`,
`${frameworkGuide}\n\n# Canonical documentation locations\n\n- Framework and package documentation: https://wrnexusjs.dev/\n- Interactive UI component showcase and examples: https://component.wrnexusjs.dev/\n- Comprehensive AI reference: https://wrnexusjs.dev/llms-full.txt\n\n# Installed package index\n\n${packageIndex}\n\n# UI component catalog\n\nThe installed @wrnexus/ui ${version} release contains ${uiReference?.count ?? 0} documented components. The contracts below include every mount name, purpose, prop type, required/default status, slot, and event. Interactive examples live only on the dedicated component showcase.\n\n${uiReferenceText}\n`,
);
writeFileSync(
join(pub, "llms-full.txt"),
`${frameworkGuide}\n\n# Canonical documentation locations\n\n- Framework and package documentation: https://wrnexusjs.dev/\n- Interactive UI component showcase and examples: https://component.wrnexusjs.dev/\n\n${packageMarker}\n\nThe following README files and declarations come from the installed private ${version} release.\n\n${installedPackageDocs}\n\n# Complete @wrnexus/ui component reference and source contracts\n\n${componentSources}\n`,
);
const auditDocs: Record<string, string> = {