@nikala-ui/folio 0.15.0 → 0.15.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.
- package/dist/cli/commands/init.js +89 -54
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/search/provider.d.ts +9 -0
- package/dist/search/provider.js +4 -2
- package/dist/server/plugin/virtual-modules.js +34 -1
- package/dist/templates/env.d.ts +26 -0
- package/dist/templates/locales/en.json +77 -0
- package/dist/themes/default/components/docs-landing-body.d.ts +17 -0
- package/dist/themes/default/components/docs-landing-body.jsx +17 -0
- package/dist/themes/default/components/docs-page-body.d.ts +21 -0
- package/dist/themes/default/components/docs-page-body.jsx +36 -0
- package/dist/themes/default/components/page-actions.d.ts +15 -0
- package/dist/themes/default/components/page-actions.jsx +60 -0
- package/dist/themes/default/components/page-header.d.ts +7 -0
- package/dist/themes/default/components/page-header.jsx +3 -0
- package/dist/themes/default/components/sidebar-footer.d.ts +6 -0
- package/dist/themes/default/components/sidebar-footer.jsx +12 -0
- package/dist/themes/default/components/sidebar-header.d.ts +8 -0
- package/dist/themes/default/components/sidebar-header.jsx +17 -0
- package/dist/themes/default/components/sidebar-mobile-nav.d.ts +7 -0
- package/dist/themes/default/components/sidebar-mobile-nav.jsx +17 -0
- package/dist/themes/default/components/sidebar-promo.d.ts +8 -0
- package/dist/themes/default/components/sidebar-promo.jsx +20 -0
- package/dist/themes/default/hooks/use-page-copy.d.ts +6 -0
- package/dist/themes/default/hooks/use-page-copy.js +26 -0
- package/dist/themes/default/layout.jsx +23 -147
- package/dist/themes/default/lib/layout-visibility.d.ts +8 -0
- package/dist/themes/default/lib/layout-visibility.js +24 -0
- package/dist/themes/default/navigation/mobile-table-of-contents.jsx +2 -2
- package/dist/themes/default/sidebar.jsx +17 -47
- package/dist/vendor/docs-src/client/page-actions.ts +69 -0
- package/dist/vendor/docs-src/navigation/index.ts +2 -0
- package/dist/vendor/docs-src/navigation/repository-links.ts +43 -0
- package/dist/vendor/docs-src/navigation/sidebar-state.ts +22 -0
- package/dist/vendor/docs-src/navigation/sidebar-tree.ts +15 -0
- package/dist/vendor/docs-src/search/provider.ts +83 -0
- package/dist/vendor/docs-src/themes/default/components/docs-landing-body.tsx +30 -0
- package/dist/vendor/docs-src/themes/default/components/docs-page-body.tsx +53 -0
- package/dist/vendor/docs-src/themes/default/components/page-actions.tsx +105 -0
- package/dist/vendor/docs-src/themes/default/components/page-header.tsx +31 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-footer.tsx +21 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-header.tsx +30 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-mobile-nav.tsx +33 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-promo.tsx +37 -0
- package/dist/vendor/docs-src/themes/default/content/breadcrumbs.tsx +43 -0
- package/dist/vendor/docs-src/themes/default/content/pager.tsx +19 -0
- package/dist/vendor/docs-src/themes/default/content/table-of-contents.tsx +32 -0
- package/dist/vendor/docs-src/themes/default/hooks/use-page-copy.ts +29 -0
- package/dist/vendor/docs-src/themes/default/icons.ts +16 -0
- package/dist/vendor/docs-src/themes/default/index.ts +46 -0
- package/dist/vendor/docs-src/themes/default/layout.tsx +176 -0
- package/dist/vendor/docs-src/themes/default/lib/layout-visibility.ts +39 -0
- package/dist/vendor/docs-src/themes/default/navbar.tsx +130 -0
- package/dist/vendor/docs-src/themes/default/navigation/mobile-table-of-contents.tsx +61 -0
- package/dist/vendor/docs-src/themes/default/navigation/sidebar-tree.tsx +202 -0
- package/dist/vendor/docs-src/themes/default/overlays/search-dialog.tsx +106 -0
- package/dist/vendor/docs-src/themes/default/sidebar.tsx +86 -0
- package/dist/vendor/docs-src/themes/index.ts +4 -0
- package/dist/vendor/docs-src/themes/types.ts +87 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function textContent(node: Node): string {
|
|
2
|
+
return node.textContent?.replace(/\s+/g, " ").trim() || "";
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function renderInline(node: Node): string {
|
|
6
|
+
if (node.nodeType === Node.TEXT_NODE) return node.textContent || "";
|
|
7
|
+
if (!(node instanceof HTMLElement)) return "";
|
|
8
|
+
|
|
9
|
+
const content = Array.from(node.childNodes).map(renderInline).join("");
|
|
10
|
+
if (node.tagName === "A") {
|
|
11
|
+
const href = node.getAttribute("href");
|
|
12
|
+
return href ? `[${content.trim()}](${href})` : content;
|
|
13
|
+
}
|
|
14
|
+
if (node.tagName === "CODE" && node.parentElement?.tagName !== "PRE") return `\`${content.trim()}\``;
|
|
15
|
+
return content;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function renderBlock(node: Node): string {
|
|
19
|
+
if (node.nodeType === Node.TEXT_NODE) return textContent(node);
|
|
20
|
+
if (!(node instanceof HTMLElement)) return "";
|
|
21
|
+
|
|
22
|
+
if (/^H[1-6]$/.test(node.tagName)) {
|
|
23
|
+
const level = Number(node.tagName.slice(1));
|
|
24
|
+
return `${"#".repeat(level)} ${renderInline(node).trim()}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (node.tagName === "PRE") return `\`\`\`\n${node.textContent?.trim() || ""}\n\`\`\``;
|
|
28
|
+
if (node.tagName === "LI") return `- ${renderInline(node).trim()}`;
|
|
29
|
+
|
|
30
|
+
const content = Array.from(node.childNodes).map(renderBlock).filter(Boolean).join("\n\n");
|
|
31
|
+
return content || renderInline(node).trim();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function pageToMarkdown(article: HTMLElement): string {
|
|
35
|
+
return Array.from(article.children)
|
|
36
|
+
.map(renderBlock)
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.join("\n\n")
|
|
39
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
40
|
+
.trim();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function sourceToMarkdown(source: string): string {
|
|
44
|
+
return source
|
|
45
|
+
.replace(/^---\s*\n[\s\S]*?\n---\s*\n?/, "")
|
|
46
|
+
.trim();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function pageToText(article: HTMLElement): string {
|
|
50
|
+
return article.innerText.trim();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function resolvePageActionUrl(
|
|
54
|
+
template: string,
|
|
55
|
+
values: { url: string; content: string; title?: string; prompt?: string },
|
|
56
|
+
): string {
|
|
57
|
+
const prompt = values.prompt
|
|
58
|
+
? values.prompt
|
|
59
|
+
.replaceAll("{url}", values.url)
|
|
60
|
+
.replaceAll("{content}", values.content)
|
|
61
|
+
.replaceAll("{title}", values.title || "")
|
|
62
|
+
: "";
|
|
63
|
+
|
|
64
|
+
return template
|
|
65
|
+
.replaceAll("{url}", encodeURIComponent(values.url))
|
|
66
|
+
.replaceAll("{content}", encodeURIComponent(values.content))
|
|
67
|
+
.replaceAll("{title}", encodeURIComponent(values.title || ""))
|
|
68
|
+
.replaceAll("{prompt}", encodeURIComponent(prompt));
|
|
69
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { DocsConfig } from "../types.js";
|
|
2
|
+
|
|
3
|
+
function normalizeRepositoryPath(...parts: string[]): string | undefined {
|
|
4
|
+
const segments = parts
|
|
5
|
+
.flatMap((part) => part.replace(/\\/g, "/").split("/"))
|
|
6
|
+
.filter((segment) => segment && segment !== ".");
|
|
7
|
+
|
|
8
|
+
if (segments.some((segment) => segment === "..")) return undefined;
|
|
9
|
+
return segments.map((segment) => encodeURIComponent(segment)).join("/");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function repositoryBaseUrl(url: string): string | undefined {
|
|
13
|
+
try {
|
|
14
|
+
const parsed = new URL(url);
|
|
15
|
+
if (!parsed.protocol.startsWith("http")) return undefined;
|
|
16
|
+
return parsed.toString().replace(/\/$/, "").replace(/\.git$/, "");
|
|
17
|
+
} catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getRepositorySourceUrl(
|
|
23
|
+
repository: NonNullable<DocsConfig["repository"]>,
|
|
24
|
+
sourcePath: string,
|
|
25
|
+
contentDir = "docs",
|
|
26
|
+
): string | undefined {
|
|
27
|
+
const baseUrl = repositoryBaseUrl(repository.url);
|
|
28
|
+
const filePath = normalizeRepositoryPath(repository.rootDir || "", contentDir, sourcePath);
|
|
29
|
+
if (!baseUrl || !filePath) return undefined;
|
|
30
|
+
|
|
31
|
+
const branch = encodeURIComponent(repository.branch || "main");
|
|
32
|
+
const hostname = new URL(baseUrl).hostname.toLowerCase();
|
|
33
|
+
|
|
34
|
+
if (hostname === "gitlab.com" || hostname.endsWith(".gitlab.com")) {
|
|
35
|
+
return `${baseUrl}/-/blob/${branch}/${filePath}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (hostname === "bitbucket.org" || hostname.endsWith(".bitbucket.org")) {
|
|
39
|
+
return `${baseUrl}/src/${branch}/${filePath}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return `${baseUrl}/blob/${branch}/${filePath}`;
|
|
43
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SidebarItem } from "../types.js";
|
|
2
|
+
|
|
3
|
+
export function isSidebarItemActive(item: SidebarItem, currentUrl?: string): boolean {
|
|
4
|
+
return Boolean(item.href && currentUrl && item.href === currentUrl);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function containsActiveSidebarItem(item: SidebarItem, currentUrl?: string): boolean {
|
|
8
|
+
return isSidebarItemActive(item, currentUrl)
|
|
9
|
+
|| Boolean(item.items?.some((child) => containsActiveSidebarItem(child, currentUrl)));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isSidebarItemNew(item: SidebarItem): boolean {
|
|
13
|
+
if (!item.addedAt) return false;
|
|
14
|
+
const timestamp = new Date(item.addedAt).getTime();
|
|
15
|
+
if (!Number.isFinite(timestamp)) return false;
|
|
16
|
+
const ageInDays = (Date.now() - timestamp) / (1000 * 60 * 60 * 24);
|
|
17
|
+
return ageInDays >= 0 && ageInDays <= 14;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function containsNewSidebarItem(item: SidebarItem): boolean {
|
|
21
|
+
return isSidebarItemNew(item) || Boolean(item.items?.some(containsNewSidebarItem));
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SidebarItem } from "../types.js";
|
|
2
|
+
|
|
3
|
+
export interface FlatSidebarItem {
|
|
4
|
+
title: string;
|
|
5
|
+
href: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function flattenSidebarItems(items: SidebarItem[]): FlatSidebarItem[] {
|
|
9
|
+
const flattened: FlatSidebarItem[] = [];
|
|
10
|
+
for (const item of items) {
|
|
11
|
+
if (item.href) flattened.push({ title: item.title, href: item.href });
|
|
12
|
+
if (item.items) flattened.push(...flattenSidebarItems(item.items));
|
|
13
|
+
}
|
|
14
|
+
return flattened;
|
|
15
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { DocsConfig, PageData } from "../types.js";
|
|
2
|
+
|
|
3
|
+
export const LOCAL_SEARCH_PROVIDER = "local";
|
|
4
|
+
|
|
5
|
+
export interface SearchContext {
|
|
6
|
+
query: string;
|
|
7
|
+
pages: PageData[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface SearchAdapterRuntime {
|
|
11
|
+
/** Browser module that exports the adapter factory. */
|
|
12
|
+
module: string;
|
|
13
|
+
/** Named export containing a factory that receives the optional adapter options. */
|
|
14
|
+
exportName: string;
|
|
15
|
+
/** JSON-serializable options passed to the browser adapter factory. */
|
|
16
|
+
options?: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SearchAdapter {
|
|
20
|
+
name: string;
|
|
21
|
+
search: (context: SearchContext) => PageData[] | Promise<PageData[]>;
|
|
22
|
+
runtime?: SearchAdapterRuntime;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type ConfiguredSearchProvider = NonNullable<DocsConfig["search"]>["provider"];
|
|
26
|
+
|
|
27
|
+
export interface ResolvedSearchProvider {
|
|
28
|
+
requested: string;
|
|
29
|
+
active: string;
|
|
30
|
+
fallback: boolean;
|
|
31
|
+
implementation: SearchAdapter;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const localSearchAdapter: SearchAdapter = {
|
|
35
|
+
name: LOCAL_SEARCH_PROVIDER,
|
|
36
|
+
search({ query, pages }) {
|
|
37
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
38
|
+
if (!normalizedQuery) return pages;
|
|
39
|
+
|
|
40
|
+
return pages.filter((page) =>
|
|
41
|
+
[page.title, page.url, page.description]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.some((value) => value!.toLowerCase().includes(normalizedQuery))
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the configured search provider to an implementation available in
|
|
50
|
+
* the default theme. External indexes can be added later without changing
|
|
51
|
+
* the configuration contract or leaving the search dialog non-functional.
|
|
52
|
+
*/
|
|
53
|
+
export function resolveSearchProvider(search?: DocsConfig["search"]): ResolvedSearchProvider {
|
|
54
|
+
const configuredProvider = search?.provider;
|
|
55
|
+
|
|
56
|
+
if (configuredProvider && typeof configuredProvider !== "string" && typeof configuredProvider.search === "function") {
|
|
57
|
+
return {
|
|
58
|
+
requested: configuredProvider.name,
|
|
59
|
+
active: configuredProvider.name,
|
|
60
|
+
fallback: false,
|
|
61
|
+
implementation: configuredProvider,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const requested = typeof configuredProvider === "string"
|
|
66
|
+
? configuredProvider.trim() || LOCAL_SEARCH_PROVIDER
|
|
67
|
+
: configuredProvider?.name || LOCAL_SEARCH_PROVIDER;
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
requested,
|
|
71
|
+
active: LOCAL_SEARCH_PROVIDER,
|
|
72
|
+
fallback: requested !== LOCAL_SEARCH_PROVIDER,
|
|
73
|
+
implementation: localSearchAdapter,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function searchPages(
|
|
78
|
+
provider: ResolvedSearchProvider,
|
|
79
|
+
query: string,
|
|
80
|
+
pages: PageData[],
|
|
81
|
+
): PageData[] | Promise<PageData[]> {
|
|
82
|
+
return provider.implementation.search({ query, pages });
|
|
83
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Show, type Component, type JSX } from "solid-js";
|
|
2
|
+
import { Container } from "@/components/ui/container";
|
|
3
|
+
import { DocsBreadcrumbs } from "../content/breadcrumbs.jsx";
|
|
4
|
+
import { DocsPager } from "../content/pager.jsx";
|
|
5
|
+
import type { BreadcrumbItemData } from "../../types.js";
|
|
6
|
+
|
|
7
|
+
export interface DocsLandingBodyProps {
|
|
8
|
+
breadcrumbs?: BreadcrumbItemData[];
|
|
9
|
+
showBreadcrumbs: boolean;
|
|
10
|
+
showPager: boolean;
|
|
11
|
+
prev?: { title: string; href: string };
|
|
12
|
+
next?: { title: string; href: string };
|
|
13
|
+
children?: JSX.Element;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const DocsLandingBody: Component<DocsLandingBodyProps> = (props) => (
|
|
17
|
+
<Container as="main" size="2xl" class="min-w-0 max-w-full flex-1 py-8 sm:py-12 lg:py-16">
|
|
18
|
+
<Container as="article" size="xl" class="mx-auto min-w-0 px-0 sm:px-4">
|
|
19
|
+
<Show when={props.showBreadcrumbs && props.breadcrumbs && props.breadcrumbs.length > 0}>
|
|
20
|
+
<DocsBreadcrumbs items={props.breadcrumbs!} class="mb-6" />
|
|
21
|
+
</Show>
|
|
22
|
+
<Container as="div" size="full" class="prose prose-zinc dark:prose-invert max-w-none px-0" data-docs-page-content>
|
|
23
|
+
{props.children}
|
|
24
|
+
</Container>
|
|
25
|
+
<Show when={props.showPager && (props.prev || props.next)}>
|
|
26
|
+
<DocsPager prev={props.prev} next={props.next} />
|
|
27
|
+
</Show>
|
|
28
|
+
</Container>
|
|
29
|
+
</Container>
|
|
30
|
+
);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Show, type Component, type JSX } from "solid-js";
|
|
2
|
+
import { Container } from "@/components/ui/container";
|
|
3
|
+
import { DocsBreadcrumbs } from "../content/breadcrumbs.jsx";
|
|
4
|
+
import { DocsPager } from "../content/pager.jsx";
|
|
5
|
+
import { DocsTableOfContents } from "../content/table-of-contents.jsx";
|
|
6
|
+
import { DocsMobileTableOfContents } from "../navigation/mobile-table-of-contents.jsx";
|
|
7
|
+
import { SidebarPromo } from "./sidebar-promo.jsx";
|
|
8
|
+
import type { BreadcrumbItemData } from "../../types.js";
|
|
9
|
+
import type { PageData, TocItem } from "../../../types.js";
|
|
10
|
+
|
|
11
|
+
export interface DocsPageBodyProps {
|
|
12
|
+
breadcrumbs?: BreadcrumbItemData[];
|
|
13
|
+
currentPage?: PageData;
|
|
14
|
+
toc?: TocItem[];
|
|
15
|
+
prev?: { title: string; href: string };
|
|
16
|
+
next?: { title: string; href: string };
|
|
17
|
+
showToc: boolean;
|
|
18
|
+
pageActions: JSX.Element;
|
|
19
|
+
sidebarPromo?: NonNullable<NonNullable<import("../../../types.js").DocsNavigationConfig["sidebar"]>["promo"]>;
|
|
20
|
+
children?: JSX.Element;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const DocsPageBody: Component<DocsPageBodyProps> = (props) => (
|
|
24
|
+
<Container as="main" size="2xl" class="min-w-0 w-full max-w-[96rem] flex-1 grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_16rem] items-start gap-4 sm:gap-8 py-6 sm:py-8">
|
|
25
|
+
<Container as="article" size="full" class="min-w-0 max-w-none mx-0 px-0 sm:px-4 w-full">
|
|
26
|
+
<Show when={props.breadcrumbs && props.breadcrumbs.length > 0}>
|
|
27
|
+
<DocsBreadcrumbs items={props.breadcrumbs!} class="mb-6" />
|
|
28
|
+
</Show>
|
|
29
|
+
<Show when={props.currentPage?.title}>
|
|
30
|
+
{props.pageActions}
|
|
31
|
+
</Show>
|
|
32
|
+
<Show when={props.showToc}>
|
|
33
|
+
<DocsMobileTableOfContents items={props.toc!} class="mb-6" />
|
|
34
|
+
</Show>
|
|
35
|
+
<Container as="div" size="full" class="prose prose-zinc dark:prose-invert max-w-none px-0 sm:px-0 lg:px-0" data-docs-page-content>
|
|
36
|
+
{props.children}
|
|
37
|
+
</Container>
|
|
38
|
+
<Show when={props.prev || props.next}>
|
|
39
|
+
<DocsPager prev={props.prev} next={props.next} />
|
|
40
|
+
</Show>
|
|
41
|
+
</Container>
|
|
42
|
+
<Show when={props.showToc && props.currentPage?.url} keyed>
|
|
43
|
+
<Container as="aside" size="sm" class="hidden xl:block w-64 shrink-0 self-start px-0 sticky top-14 z-10 h-fit max-h-[calc(100vh-3.5rem)] overflow-y-auto bg-background">
|
|
44
|
+
<div class="flex flex-col gap-5">
|
|
45
|
+
<DocsTableOfContents items={props.toc!} class="max-h-none" />
|
|
46
|
+
<Show when={props.sidebarPromo}>
|
|
47
|
+
{(promo) => <SidebarPromo promo={promo()} />}
|
|
48
|
+
</Show>
|
|
49
|
+
</div>
|
|
50
|
+
</Container>
|
|
51
|
+
</Show>
|
|
52
|
+
</Container>
|
|
53
|
+
);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { For, Show, type Accessor, type Component } from "solid-js";
|
|
2
|
+
import { ChevronDown, Copy, ExternalLink, FileText } from "lucide-solid";
|
|
3
|
+
import { Button, buttonVariants } from "@/components/ui/button";
|
|
4
|
+
import {
|
|
5
|
+
DropdownMenu,
|
|
6
|
+
DropdownMenuContent,
|
|
7
|
+
DropdownMenuItem,
|
|
8
|
+
DropdownMenuTrigger,
|
|
9
|
+
} from "@/components/ui/dropdown-menu";
|
|
10
|
+
import { cn } from "@/lib/cn";
|
|
11
|
+
import { resolvePageActionUrl } from "../../../client/page-actions.js";
|
|
12
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
13
|
+
import type { DocsAiProvider, DocsPageAction } from "../../../types.js";
|
|
14
|
+
|
|
15
|
+
export interface PageActionsProps {
|
|
16
|
+
sourceUrl?: string;
|
|
17
|
+
pageActions: readonly DocsPageAction[];
|
|
18
|
+
aiProviders: readonly DocsAiProvider[];
|
|
19
|
+
copyPageEnabled: boolean;
|
|
20
|
+
copyMarkdownEnabled: boolean;
|
|
21
|
+
pageUrl?: string;
|
|
22
|
+
pageTitle?: string;
|
|
23
|
+
markdown: Accessor<string>;
|
|
24
|
+
onCopyPage: () => void;
|
|
25
|
+
onCopyMarkdown: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const PageActions: Component<PageActionsProps> = (props) => {
|
|
29
|
+
const siteLocale = useSiteLocale();
|
|
30
|
+
const hasCopyActions = () => props.copyPageEnabled || props.copyMarkdownEnabled || props.aiProviders.length > 0;
|
|
31
|
+
const providerUrl = (provider: DocsAiProvider) => resolvePageActionUrl(provider.url, {
|
|
32
|
+
url: typeof window !== "undefined" ? window.location.href : props.pageUrl || "",
|
|
33
|
+
content: props.markdown(),
|
|
34
|
+
title: props.pageTitle,
|
|
35
|
+
prompt: provider.prompt,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div class="flex items-center gap-2">
|
|
40
|
+
<Show when={props.sourceUrl}>
|
|
41
|
+
{(url) => (
|
|
42
|
+
<a
|
|
43
|
+
href={url()}
|
|
44
|
+
target="_blank"
|
|
45
|
+
rel="noreferrer"
|
|
46
|
+
class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}
|
|
47
|
+
>
|
|
48
|
+
{siteLocale.t("actions.viewSource")}
|
|
49
|
+
</a>
|
|
50
|
+
)}
|
|
51
|
+
</Show>
|
|
52
|
+
<For each={props.pageActions}>
|
|
53
|
+
{(action) => (
|
|
54
|
+
<a
|
|
55
|
+
href={action.href}
|
|
56
|
+
target={action.external ? "_blank" : undefined}
|
|
57
|
+
rel={action.external ? "noreferrer" : undefined}
|
|
58
|
+
class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}
|
|
59
|
+
>
|
|
60
|
+
{action.label}
|
|
61
|
+
</a>
|
|
62
|
+
)}
|
|
63
|
+
</For>
|
|
64
|
+
<Show when={hasCopyActions()}>
|
|
65
|
+
<DropdownMenu placement="bottom-end">
|
|
66
|
+
<DropdownMenuTrigger
|
|
67
|
+
as={Button}
|
|
68
|
+
variant="secondary"
|
|
69
|
+
size="sm"
|
|
70
|
+
class="shrink-0 gap-1"
|
|
71
|
+
aria-label={siteLocale.t("actions.copyDocumentationPage")}
|
|
72
|
+
>
|
|
73
|
+
<Copy class="size-3.5" />
|
|
74
|
+
<span class="hidden sm:inline">{siteLocale.t("actions.copyPage")}</span>
|
|
75
|
+
<ChevronDown class="size-3.5" />
|
|
76
|
+
</DropdownMenuTrigger>
|
|
77
|
+
<DropdownMenuContent>
|
|
78
|
+
<Show when={props.copyPageEnabled}>
|
|
79
|
+
<DropdownMenuItem onClick={props.onCopyPage}>
|
|
80
|
+
<FileText class="mr-2 size-4" />
|
|
81
|
+
{siteLocale.t("actions.copyPage")}
|
|
82
|
+
</DropdownMenuItem>
|
|
83
|
+
</Show>
|
|
84
|
+
<Show when={props.copyMarkdownEnabled}>
|
|
85
|
+
<DropdownMenuItem onClick={props.onCopyMarkdown}>
|
|
86
|
+
<Copy class="mr-2 size-4" />
|
|
87
|
+
{siteLocale.t("actions.copyAsMarkdown")}
|
|
88
|
+
</DropdownMenuItem>
|
|
89
|
+
</Show>
|
|
90
|
+
<Show when={props.aiProviders.length > 0}>
|
|
91
|
+
<For each={props.aiProviders}>
|
|
92
|
+
{(provider) => (
|
|
93
|
+
<DropdownMenuItem as="a" href={providerUrl(provider)} target="_blank" rel="noreferrer">
|
|
94
|
+
<ExternalLink class="mr-2 size-4" />
|
|
95
|
+
{siteLocale.t("actions.openInProvider", { provider: provider.name })}
|
|
96
|
+
</DropdownMenuItem>
|
|
97
|
+
)}
|
|
98
|
+
</For>
|
|
99
|
+
</Show>
|
|
100
|
+
</DropdownMenuContent>
|
|
101
|
+
</DropdownMenu>
|
|
102
|
+
</Show>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SectionHeading } from "@/components/ui/section-heading";
|
|
2
|
+
import type { Component } from "solid-js";
|
|
3
|
+
import { PageActions, type PageActionsProps } from "./page-actions.jsx";
|
|
4
|
+
|
|
5
|
+
export interface PageHeaderProps extends PageActionsProps {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const PageHeader: Component<PageHeaderProps> = (props) => (
|
|
11
|
+
<SectionHeading
|
|
12
|
+
variant="page"
|
|
13
|
+
title={props.title}
|
|
14
|
+
description={props.description}
|
|
15
|
+
class="mb-8"
|
|
16
|
+
actions={
|
|
17
|
+
<PageActions
|
|
18
|
+
sourceUrl={props.sourceUrl}
|
|
19
|
+
pageActions={props.pageActions}
|
|
20
|
+
aiProviders={props.aiProviders}
|
|
21
|
+
copyPageEnabled={props.copyPageEnabled}
|
|
22
|
+
copyMarkdownEnabled={props.copyMarkdownEnabled}
|
|
23
|
+
pageUrl={props.pageUrl}
|
|
24
|
+
pageTitle={props.pageTitle}
|
|
25
|
+
markdown={props.markdown}
|
|
26
|
+
onCopyPage={props.onCopyPage}
|
|
27
|
+
onCopyMarkdown={props.onCopyMarkdown}
|
|
28
|
+
/>
|
|
29
|
+
}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SidebarFooter as UiSidebarFooter, SidebarMenuButton } from "@/components/ui/sidebar";
|
|
2
|
+
import type { Component } from "solid-js";
|
|
3
|
+
|
|
4
|
+
export interface SidebarFooterProps {
|
|
5
|
+
brandText: string;
|
|
6
|
+
footerText?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const SidebarFooter: Component<SidebarFooterProps> = (props) => (
|
|
10
|
+
<UiSidebarFooter class="p-2">
|
|
11
|
+
<SidebarMenuButton size="lg" class="w-full justify-start">
|
|
12
|
+
<div class="flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/15 text-xs font-bold text-primary">
|
|
13
|
+
N
|
|
14
|
+
</div>
|
|
15
|
+
<div class="flex min-w-0 flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
|
|
16
|
+
<span class="truncate text-xs font-semibold">{props.brandText}</span>
|
|
17
|
+
<span class="truncate text-[10px] text-muted-foreground">{props.footerText}</span>
|
|
18
|
+
</div>
|
|
19
|
+
</SidebarMenuButton>
|
|
20
|
+
</UiSidebarFooter>
|
|
21
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Show, type Component } from "solid-js";
|
|
2
|
+
import { Logo } from "@/components/ui/logo";
|
|
3
|
+
import { cn } from "@/lib/cn";
|
|
4
|
+
import { SidebarHeader as UiSidebarHeader, SidebarMenuButton } from "@/components/ui/sidebar";
|
|
5
|
+
import type { DocsConfig } from "../../../types.js";
|
|
6
|
+
|
|
7
|
+
export interface SidebarHeaderProps {
|
|
8
|
+
logo?: DocsConfig["logo"];
|
|
9
|
+
brandText: string;
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const SidebarHeader: Component<SidebarHeaderProps> = (props) => (
|
|
14
|
+
<UiSidebarHeader class="h-14 box-border p-3 group-data-[collapsible=icon]:p-2">
|
|
15
|
+
<SidebarMenuButton
|
|
16
|
+
href={props.logo?.href || "/"}
|
|
17
|
+
class={cn("h-8 w-full justify-between group-data-[collapsible=icon]:h-10")}
|
|
18
|
+
>
|
|
19
|
+
<div class="flex items-center gap-2.5 overflow-hidden">
|
|
20
|
+
<Show when={props.logo?.image} fallback={<Logo class="h-7 w-auto" />}>
|
|
21
|
+
{(image) => <img src={image()} alt={props.brandText} class="size-7 shrink-0 rounded-md object-contain" />}
|
|
22
|
+
</Show>
|
|
23
|
+
<div class="flex min-w-0 flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
|
|
24
|
+
<span class="truncate text-xs font-bold">{props.brandText}</span>
|
|
25
|
+
<span class="truncate text-[10px] text-muted-foreground">{props.subtitle}</span>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</SidebarMenuButton>
|
|
29
|
+
</UiSidebarHeader>
|
|
30
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { For, type Component } from "solid-js";
|
|
2
|
+
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar";
|
|
3
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
4
|
+
import type { NavItem } from "../../../types.js";
|
|
5
|
+
|
|
6
|
+
export interface SidebarMobileNavProps {
|
|
7
|
+
items?: NavItem[];
|
|
8
|
+
onNavigate: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const SidebarMobileNav: Component<SidebarMobileNavProps> = (props) => {
|
|
12
|
+
const siteLocale = useSiteLocale();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<nav aria-label={siteLocale.t("navigation.primary")} class="border-b border-border/60 px-2 py-2 md:hidden">
|
|
16
|
+
<SidebarMenu>
|
|
17
|
+
<For each={props.items}>
|
|
18
|
+
{(item) => (
|
|
19
|
+
<SidebarMenuItem>
|
|
20
|
+
<SidebarMenuButton
|
|
21
|
+
href={item.href}
|
|
22
|
+
onClick={props.onNavigate}
|
|
23
|
+
class="w-full justify-start text-sm font-normal"
|
|
24
|
+
>
|
|
25
|
+
{item.title}
|
|
26
|
+
</SidebarMenuButton>
|
|
27
|
+
</SidebarMenuItem>
|
|
28
|
+
)}
|
|
29
|
+
</For>
|
|
30
|
+
</SidebarMenu>
|
|
31
|
+
</nav>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ExternalLink } from "lucide-solid";
|
|
2
|
+
import { Card, CardContent, CardDescription, CardTitle } from "@/components/ui/card";
|
|
3
|
+
import { buttonVariants } from "@/components/ui/button";
|
|
4
|
+
import { cn } from "@/lib/cn";
|
|
5
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
6
|
+
import type { DocsNavigationConfig } from "../../../types.js";
|
|
7
|
+
import type { Component } from "solid-js";
|
|
8
|
+
|
|
9
|
+
type SidebarPromoData = NonNullable<NonNullable<DocsNavigationConfig["sidebar"]>["promo"]>;
|
|
10
|
+
|
|
11
|
+
export interface SidebarPromoProps {
|
|
12
|
+
promo: SidebarPromoData;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const SidebarPromo: Component<SidebarPromoProps> = (props) => {
|
|
16
|
+
const siteLocale = useSiteLocale();
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Card class="border-primary/30 bg-primary/5 shadow-none">
|
|
20
|
+
<CardContent class="p-4">
|
|
21
|
+
<CardTitle class="text-sm">{props.promo.title}</CardTitle>
|
|
22
|
+
<CardDescription class="mt-2 text-xs leading-relaxed">
|
|
23
|
+
{props.promo.description}
|
|
24
|
+
</CardDescription>
|
|
25
|
+
<a
|
|
26
|
+
href={props.promo.href}
|
|
27
|
+
target="_blank"
|
|
28
|
+
rel="noreferrer"
|
|
29
|
+
class={cn(buttonVariants({ variant: "outline", size: "sm" }), "mt-4 h-8 w-full gap-1.5 text-xs")}
|
|
30
|
+
>
|
|
31
|
+
{props.promo.cta || siteLocale.t("actions.learnMore")}
|
|
32
|
+
<ExternalLink class="size-3" aria-hidden="true" />
|
|
33
|
+
</a>
|
|
34
|
+
</CardContent>
|
|
35
|
+
</Card>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/content/breadcrumbs.tsx
|
|
2
|
+
import { For, Show, splitProps, type Component } from "solid-js";
|
|
3
|
+
import { Breadcrumb } from "@/components/ui/breadcrumb";
|
|
4
|
+
import { BreadcrumbList } from "@/components/ui/breadcrumb";
|
|
5
|
+
import { BreadcrumbItem } from "@/components/ui/breadcrumb";
|
|
6
|
+
import { BreadcrumbLink } from "@/components/ui/breadcrumb";
|
|
7
|
+
import { BreadcrumbSeparator } from "@/components/ui/breadcrumb";
|
|
8
|
+
import { BreadcrumbPage } from "@/components/ui/breadcrumb";
|
|
9
|
+
import type { DocsBreadcrumbsProps } from "../../types.js";
|
|
10
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
11
|
+
|
|
12
|
+
export const DocsBreadcrumbs: Component<DocsBreadcrumbsProps> = (props) => {
|
|
13
|
+
const [local, rest] = splitProps(props, ["items", "class"]);
|
|
14
|
+
const siteLocale = useSiteLocale();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Breadcrumb class={local.class} {...rest}>
|
|
18
|
+
<BreadcrumbList>
|
|
19
|
+
<For each={local.items}>
|
|
20
|
+
{(item, index) => {
|
|
21
|
+
const isLast = () => index() === local.items.length - 1;
|
|
22
|
+
const title = () => item.href === "/" ? siteLocale.t("navigation.documentation") : item.title;
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<BreadcrumbItem>
|
|
26
|
+
<Show
|
|
27
|
+
when={!isLast() && item.href}
|
|
28
|
+
fallback={<BreadcrumbPage>{title()}</BreadcrumbPage>}
|
|
29
|
+
>
|
|
30
|
+
<BreadcrumbLink href={item.href}>{title()}</BreadcrumbLink>
|
|
31
|
+
</Show>
|
|
32
|
+
</BreadcrumbItem>
|
|
33
|
+
<Show when={!isLast()}>
|
|
34
|
+
<BreadcrumbSeparator />
|
|
35
|
+
</Show>
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}}
|
|
39
|
+
</For>
|
|
40
|
+
</BreadcrumbList>
|
|
41
|
+
</Breadcrumb>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/content/pager.tsx
|
|
2
|
+
import { splitProps, type Component } from "solid-js";
|
|
3
|
+
import { Pager as CorePager } from "@/components/ui/pager";
|
|
4
|
+
import type { DocsPagerProps } from "../../types.js";
|
|
5
|
+
|
|
6
|
+
export const DocsPager: Component<DocsPagerProps> = (props) => {
|
|
7
|
+
const [local, rest] = splitProps(props, ["prev", "next", "class"]);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<CorePager
|
|
11
|
+
prev={local.prev}
|
|
12
|
+
next={local.next}
|
|
13
|
+
class={local.class}
|
|
14
|
+
{...rest}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const DocsPagination = DocsPager;
|