@nikala-ui/folio 0.15.0 → 0.16.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/cli/commands/init.js +89 -54
- package/dist/components/ui/code-block-commands.d.ts +4 -0
- package/dist/components/ui/code-block-commands.js +58 -0
- package/dist/components/ui/code-block.d.ts +2 -1
- package/dist/components/ui/code-block.jsx +4 -127
- package/dist/components/ui/code-highlighter.d.ts +2 -0
- package/dist/components/ui/code-highlighter.js +76 -0
- package/dist/config.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/mdx/builtin-languages.d.ts +34 -0
- package/dist/mdx/builtin-languages.js +54 -0
- package/dist/mdx/custom-languages.d.ts +10 -0
- package/dist/mdx/custom-languages.js +52 -0
- package/dist/mdx/highlighter.d.ts +2 -1
- package/dist/mdx/highlighter.js +19 -52
- package/dist/search/provider.d.ts +9 -0
- package/dist/search/provider.js +4 -2
- package/dist/server/plugin/constants.d.ts +2 -0
- package/dist/server/plugin/constants.js +2 -0
- package/dist/server/plugin/index.js +2 -1
- package/dist/server/plugin/virtual-modules.js +41 -2
- package/dist/templates/env.d.ts +31 -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/types.d.ts +9 -0
- package/dist/vendor/docs-src/client/page-actions.ts +69 -0
- package/dist/vendor/docs-src/components/ui/code-block-commands.ts +65 -0
- package/dist/vendor/docs-src/components/ui/code-block.tsx +5 -132
- package/dist/vendor/docs-src/components/ui/code-highlighter.ts +76 -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 +3 -3
|
@@ -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;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/content/table-of-contents.tsx
|
|
2
|
+
import { createSignal, onMount, Show, splitProps, type Component } from "solid-js";
|
|
3
|
+
import { TableOfContents as CoreTableOfContents } from "@/components/ui/table-of-contents";
|
|
4
|
+
import type { DocsTableOfContentsProps } from "../../types.js";
|
|
5
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
6
|
+
|
|
7
|
+
export const DocsTableOfContents: Component<DocsTableOfContentsProps> = (props) => {
|
|
8
|
+
const [local, rest] = splitProps(props, ["items", "title", "class"]);
|
|
9
|
+
const [ready, setReady] = createSignal(false);
|
|
10
|
+
const siteLocale = useSiteLocale();
|
|
11
|
+
|
|
12
|
+
onMount(() => {
|
|
13
|
+
if (typeof window === "undefined") {
|
|
14
|
+
setReady(true);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const frame = window.requestAnimationFrame(() => setReady(true));
|
|
19
|
+
return () => window.cancelAnimationFrame(frame);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Show when={ready()}>
|
|
24
|
+
<CoreTableOfContents
|
|
25
|
+
items={local.items}
|
|
26
|
+
title={local.title ?? siteLocale.t("tableOfContents.title")}
|
|
27
|
+
class={local.class}
|
|
28
|
+
{...rest}
|
|
29
|
+
/>
|
|
30
|
+
</Show>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createClipboard } from "@/hooks/create-clipboard";
|
|
2
|
+
import { pageToMarkdown, pageToText, sourceToMarkdown } from "../../../client/page-actions.js";
|
|
3
|
+
import type { Accessor } from "solid-js";
|
|
4
|
+
|
|
5
|
+
function pageElement(): HTMLElement | null {
|
|
6
|
+
if (typeof document === "undefined") return null;
|
|
7
|
+
return document.querySelector("main article [data-docs-page-content]") as HTMLElement | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createPageCopy(sourceContent: Accessor<string | undefined>) {
|
|
11
|
+
const clipboard = createClipboard();
|
|
12
|
+
const markdown = () => {
|
|
13
|
+
const source = sourceContent();
|
|
14
|
+
const page = pageElement();
|
|
15
|
+
return source ? sourceToMarkdown(source) : page ? pageToMarkdown(page) : "";
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const copyPage = async () => {
|
|
19
|
+
const page = pageElement();
|
|
20
|
+
if (page) await clipboard.copy(pageToText(page));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const copyMarkdown = async () => {
|
|
24
|
+
const content = markdown();
|
|
25
|
+
if (content) await clipboard.copy(content);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return { markdown, copyPage, copyMarkdown };
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { icons } from "virtual:folio-icons";
|
|
2
|
+
import type { DocsIcon } from "../../types.js";
|
|
3
|
+
|
|
4
|
+
function toComponentName(name: string): string {
|
|
5
|
+
return name
|
|
6
|
+
.split(/[-_\s]+/)
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
9
|
+
.join("");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function resolveDefaultIcon(name?: string): DocsIcon | undefined {
|
|
13
|
+
if (!name) return undefined;
|
|
14
|
+
const icon = icons[toComponentName(name)];
|
|
15
|
+
return icon;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/index.ts
|
|
2
|
+
export * from "./layout.jsx";
|
|
3
|
+
export * from "./navbar.jsx";
|
|
4
|
+
export * from "./sidebar.jsx";
|
|
5
|
+
export * from "./content/table-of-contents.jsx";
|
|
6
|
+
export * from "./content/breadcrumbs.jsx";
|
|
7
|
+
export * from "./content/pager.jsx";
|
|
8
|
+
export * from "./overlays/search-dialog.jsx";
|
|
9
|
+
|
|
10
|
+
import { DocsLayout } from "./layout.jsx";
|
|
11
|
+
import { DocsNavbar } from "./navbar.jsx";
|
|
12
|
+
import { DocsSidebar } from "./sidebar.jsx";
|
|
13
|
+
import { DocsTableOfContents } from "./content/table-of-contents.jsx";
|
|
14
|
+
import { DocsBreadcrumbs } from "./content/breadcrumbs.jsx";
|
|
15
|
+
import { DocsPager, DocsPagination } from "./content/pager.jsx";
|
|
16
|
+
import { DocsSearchDialog } from "./overlays/search-dialog.jsx";
|
|
17
|
+
import { ThemeProvider } from "@/providers/theme-provider";
|
|
18
|
+
import type { DocsThemeContract } from "../types.js";
|
|
19
|
+
|
|
20
|
+
export type {
|
|
21
|
+
BreadcrumbItemData,
|
|
22
|
+
DocsBreadcrumbsProps,
|
|
23
|
+
DocsLayoutProps,
|
|
24
|
+
DocsNavbarProps,
|
|
25
|
+
DocsPaginationProps,
|
|
26
|
+
DocsPagerProps,
|
|
27
|
+
DocsSearchDialogProps,
|
|
28
|
+
DocsSidebarProps,
|
|
29
|
+
DocsTableOfContentsProps,
|
|
30
|
+
DocsThemeContract,
|
|
31
|
+
} from "../types.js";
|
|
32
|
+
|
|
33
|
+
export const defaultTheme: DocsThemeContract = {
|
|
34
|
+
name: "default",
|
|
35
|
+
Provider: ThemeProvider,
|
|
36
|
+
Layout: DocsLayout,
|
|
37
|
+
Navbar: DocsNavbar,
|
|
38
|
+
Sidebar: DocsSidebar,
|
|
39
|
+
TableOfContents: DocsTableOfContents,
|
|
40
|
+
Breadcrumbs: DocsBreadcrumbs,
|
|
41
|
+
Pagination: DocsPagination,
|
|
42
|
+
Pager: DocsPager,
|
|
43
|
+
SearchDialog: DocsSearchDialog,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default defaultTheme;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/layout.tsx
|
|
2
|
+
import { createSignal, Show, splitProps, type ParentComponent } from "solid-js";
|
|
3
|
+
import { SidebarProvider } from "@/components/ui/sidebar";
|
|
4
|
+
import { SidebarInset } from "@/components/ui/sidebar";
|
|
5
|
+
import { DocsNavbar } from "./navbar.jsx";
|
|
6
|
+
import { DocsSidebar } from "./sidebar.jsx";
|
|
7
|
+
import { DocsSearchDialog } from "./overlays/search-dialog.jsx";
|
|
8
|
+
import { cn } from "@/lib/cn";
|
|
9
|
+
import { getRepositorySourceUrl } from "../../navigation/repository-links.js";
|
|
10
|
+
import { resolveSearchProvider } from "../../search/provider.js";
|
|
11
|
+
import type { DocsLayoutProps } from "../types.js";
|
|
12
|
+
import { DocsPageBody } from "./components/docs-page-body.jsx";
|
|
13
|
+
import { DocsLandingBody } from "./components/docs-landing-body.jsx";
|
|
14
|
+
import { PageHeader } from "./components/page-header.jsx";
|
|
15
|
+
import { createPageCopy } from "./hooks/use-page-copy.js";
|
|
16
|
+
import {
|
|
17
|
+
isLandingPage,
|
|
18
|
+
shouldShowLandingSidebar,
|
|
19
|
+
shouldShowNavbar,
|
|
20
|
+
shouldShowSidebarFooter,
|
|
21
|
+
shouldShowSidebarHeader,
|
|
22
|
+
shouldShowToc,
|
|
23
|
+
shouldUseSidebarLayout,
|
|
24
|
+
} from "./lib/layout-visibility.js";
|
|
25
|
+
|
|
26
|
+
export const DocsLayout: ParentComponent<DocsLayoutProps> = (props) => {
|
|
27
|
+
const [local, rest] = splitProps(props, [
|
|
28
|
+
"config",
|
|
29
|
+
"tree",
|
|
30
|
+
"pages",
|
|
31
|
+
"currentPage",
|
|
32
|
+
"onNavigate",
|
|
33
|
+
"breadcrumbs",
|
|
34
|
+
"toc",
|
|
35
|
+
"prev",
|
|
36
|
+
"next",
|
|
37
|
+
"sourceContent",
|
|
38
|
+
"children",
|
|
39
|
+
"class",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
const [searchOpen, setSearchOpen] = createSignal(false);
|
|
43
|
+
const pageCopy = createPageCopy(() => local.sourceContent);
|
|
44
|
+
const searchEnabled = () => local.config.search?.enabled !== false;
|
|
45
|
+
const searchProvider = () => resolveSearchProvider(local.config.search);
|
|
46
|
+
|
|
47
|
+
const currentUrl = () => local.currentPage?.url;
|
|
48
|
+
const landingPage = () => isLandingPage(local.currentPage, local.config);
|
|
49
|
+
const showLandingSidebar = () => shouldShowLandingSidebar(local.config);
|
|
50
|
+
const showNavbar = () => shouldShowNavbar(local.config);
|
|
51
|
+
const showToc = () => shouldShowToc(local.toc, local.currentPage, local.config, landingPage());
|
|
52
|
+
const sidebarLayout = () => shouldUseSidebarLayout(local.config);
|
|
53
|
+
const sidebarHeader = () => shouldShowSidebarHeader(local.config);
|
|
54
|
+
const sidebarFooter = () => shouldShowSidebarFooter(local.config);
|
|
55
|
+
const sidebarPromo = () => local.config.navigation?.sidebar?.promo;
|
|
56
|
+
const sourceUrl = () => {
|
|
57
|
+
const page = local.currentPage;
|
|
58
|
+
const repository = local.config.repository;
|
|
59
|
+
if (!page?.sourcePath || !repository) return undefined;
|
|
60
|
+
return getRepositorySourceUrl(repository, page.sourcePath, local.config.contentDir || "docs");
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const markdown = pageCopy.markdown;
|
|
64
|
+
const aiProviders = () => local.config.pageActions?.ai || [];
|
|
65
|
+
const copyPageEnabled = () => local.config.pageActions?.copyPage !== false;
|
|
66
|
+
const copyMarkdownEnabled = () => local.config.pageActions?.copyMarkdown !== false;
|
|
67
|
+
const pageActions = () => local.currentPage?.pageActions || [];
|
|
68
|
+
|
|
69
|
+
const sidebar = (className?: string) => (
|
|
70
|
+
<DocsSidebar
|
|
71
|
+
tree={local.tree}
|
|
72
|
+
pages={local.pages}
|
|
73
|
+
nav={local.config.navigation?.navbar || local.config.nav}
|
|
74
|
+
currentUrl={currentUrl()}
|
|
75
|
+
title={local.config.title}
|
|
76
|
+
logo={local.config.logo}
|
|
77
|
+
headerSubtitle={local.config.navigation?.sidebar?.headerSubtitle}
|
|
78
|
+
footerText={local.config.navigation?.sidebar?.footerText}
|
|
79
|
+
showHeader={sidebarHeader()}
|
|
80
|
+
showFooter={sidebarFooter()}
|
|
81
|
+
class={className}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const content = () => (
|
|
86
|
+
<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
87
|
+
<DocsPageBody
|
|
88
|
+
breadcrumbs={local.breadcrumbs}
|
|
89
|
+
currentPage={local.currentPage}
|
|
90
|
+
toc={local.toc}
|
|
91
|
+
prev={local.prev}
|
|
92
|
+
next={local.next}
|
|
93
|
+
showToc={showToc()}
|
|
94
|
+
sidebarPromo={sidebarPromo()}
|
|
95
|
+
pageActions={
|
|
96
|
+
<Show when={local.currentPage?.title}>
|
|
97
|
+
<PageHeader
|
|
98
|
+
title={local.currentPage!.title}
|
|
99
|
+
description={local.currentPage?.description}
|
|
100
|
+
sourceUrl={sourceUrl()}
|
|
101
|
+
pageActions={pageActions()}
|
|
102
|
+
aiProviders={aiProviders()}
|
|
103
|
+
copyPageEnabled={copyPageEnabled()}
|
|
104
|
+
copyMarkdownEnabled={copyMarkdownEnabled()}
|
|
105
|
+
pageUrl={local.currentPage?.url}
|
|
106
|
+
pageTitle={local.currentPage?.title}
|
|
107
|
+
markdown={markdown}
|
|
108
|
+
onCopyPage={pageCopy.copyPage}
|
|
109
|
+
onCopyMarkdown={pageCopy.copyMarkdown}
|
|
110
|
+
/>
|
|
111
|
+
</Show>
|
|
112
|
+
}
|
|
113
|
+
>
|
|
114
|
+
{local.children}
|
|
115
|
+
</DocsPageBody>
|
|
116
|
+
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined} />
|
|
117
|
+
</SidebarInset>
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const landingContent = () => (
|
|
121
|
+
<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
122
|
+
<DocsLandingBody
|
|
123
|
+
breadcrumbs={local.breadcrumbs}
|
|
124
|
+
showBreadcrumbs={local.config.home?.showBreadcrumbs === true}
|
|
125
|
+
showPager={local.config.home?.showPager === true}
|
|
126
|
+
prev={local.prev}
|
|
127
|
+
next={local.next}
|
|
128
|
+
>
|
|
129
|
+
{local.children}
|
|
130
|
+
</DocsLandingBody>
|
|
131
|
+
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined} />
|
|
132
|
+
</SidebarInset>
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<SidebarProvider defaultOpen={true} class="min-h-screen w-full items-stretch">
|
|
137
|
+
<Show when={landingPage()} fallback={<Show when={sidebarLayout()} fallback={
|
|
138
|
+
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
139
|
+
<DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={true} showSidebarTrigger={false} onOpenSearch={() => setSearchOpen(true)} />
|
|
140
|
+
<div class="flex min-h-0 min-w-0 max-w-full flex-1 items-start">{content()}</div>
|
|
141
|
+
</div>
|
|
142
|
+
}>
|
|
143
|
+
{sidebar()}
|
|
144
|
+
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
145
|
+
<DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={false} onOpenSearch={() => setSearchOpen(true)} />
|
|
146
|
+
{content()}
|
|
147
|
+
</div>
|
|
148
|
+
</Show>}>
|
|
149
|
+
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
150
|
+
<Show when={showNavbar()}>
|
|
151
|
+
<DocsNavbar
|
|
152
|
+
config={local.config}
|
|
153
|
+
currentPage={local.currentPage}
|
|
154
|
+
pages={local.pages}
|
|
155
|
+
onNavigate={local.onNavigate}
|
|
156
|
+
showBrand={true}
|
|
157
|
+
showSidebarTrigger={showLandingSidebar()}
|
|
158
|
+
mobileSidebarTrigger={landingPage()}
|
|
159
|
+
onOpenSearch={() => setSearchOpen(true)}
|
|
160
|
+
/>
|
|
161
|
+
</Show>
|
|
162
|
+
<Show when={showLandingSidebar()} fallback={
|
|
163
|
+
<>
|
|
164
|
+
<Show when={landingPage()}>
|
|
165
|
+
{sidebar("md:hidden")}
|
|
166
|
+
</Show>
|
|
167
|
+
{landingContent()}
|
|
168
|
+
</>
|
|
169
|
+
}>
|
|
170
|
+
<div class="flex min-h-0 min-w-0 max-w-full flex-1 items-start">{sidebar()}{landingContent()}</div>
|
|
171
|
+
</Show>
|
|
172
|
+
</div>
|
|
173
|
+
</Show>
|
|
174
|
+
</SidebarProvider>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DocsConfig, PageData, TocItem } from "../../../types.js";
|
|
2
|
+
|
|
3
|
+
export function isLandingPage(page: PageData | undefined, config: DocsConfig): boolean {
|
|
4
|
+
return page?.url === "/" && config.home?.layout === "landing";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function shouldShowLandingSidebar(config: DocsConfig): boolean {
|
|
8
|
+
return config.home?.showSidebar === true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function shouldShowNavbar(config: DocsConfig): boolean {
|
|
12
|
+
return config.home?.showNavbar !== false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function shouldShowToc(
|
|
16
|
+
toc: TocItem[] | undefined,
|
|
17
|
+
page: PageData | undefined,
|
|
18
|
+
config: DocsConfig,
|
|
19
|
+
landingPage: boolean,
|
|
20
|
+
): boolean {
|
|
21
|
+
return Boolean(
|
|
22
|
+
toc &&
|
|
23
|
+
toc.length > 0 &&
|
|
24
|
+
page?.frontmatter?.toc !== false &&
|
|
25
|
+
(!landingPage || config.home?.showToc === true),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function shouldUseSidebarLayout(config: DocsConfig): boolean {
|
|
30
|
+
return config.navigation?.layout !== "top";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function shouldShowSidebarHeader(config: DocsConfig): boolean {
|
|
34
|
+
return config.navigation?.sidebar?.header !== false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function shouldShowSidebarFooter(config: DocsConfig): boolean {
|
|
38
|
+
return config.navigation?.sidebar?.footer !== false;
|
|
39
|
+
}
|