@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,60 @@
|
|
|
1
|
+
import { For, Show } from "solid-js";
|
|
2
|
+
import { ChevronDown, Copy, ExternalLink, FileText } from "lucide-solid";
|
|
3
|
+
import { Button, buttonVariants } from "@/components/ui/button";
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
5
|
+
import { cn } from "@/lib/cn";
|
|
6
|
+
import { resolvePageActionUrl } from "../../../client/page-actions.js";
|
|
7
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
8
|
+
export const PageActions = (props) => {
|
|
9
|
+
const siteLocale = useSiteLocale();
|
|
10
|
+
const hasCopyActions = () => props.copyPageEnabled || props.copyMarkdownEnabled || props.aiProviders.length > 0;
|
|
11
|
+
const providerUrl = (provider) => resolvePageActionUrl(provider.url, {
|
|
12
|
+
url: typeof window !== "undefined" ? window.location.href : props.pageUrl || "",
|
|
13
|
+
content: props.markdown(),
|
|
14
|
+
title: props.pageTitle,
|
|
15
|
+
prompt: provider.prompt,
|
|
16
|
+
});
|
|
17
|
+
return (<div class="flex items-center gap-2">
|
|
18
|
+
<Show when={props.sourceUrl}>
|
|
19
|
+
{(url) => (<a href={url()} target="_blank" rel="noreferrer" class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}>
|
|
20
|
+
{siteLocale.t("actions.viewSource")}
|
|
21
|
+
</a>)}
|
|
22
|
+
</Show>
|
|
23
|
+
<For each={props.pageActions}>
|
|
24
|
+
{(action) => (<a href={action.href} target={action.external ? "_blank" : undefined} rel={action.external ? "noreferrer" : undefined} class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}>
|
|
25
|
+
{action.label}
|
|
26
|
+
</a>)}
|
|
27
|
+
</For>
|
|
28
|
+
<Show when={hasCopyActions()}>
|
|
29
|
+
<DropdownMenu placement="bottom-end">
|
|
30
|
+
<DropdownMenuTrigger as={Button} variant="secondary" size="sm" class="shrink-0 gap-1" aria-label={siteLocale.t("actions.copyDocumentationPage")}>
|
|
31
|
+
<Copy class="size-3.5"/>
|
|
32
|
+
<span class="hidden sm:inline">{siteLocale.t("actions.copyPage")}</span>
|
|
33
|
+
<ChevronDown class="size-3.5"/>
|
|
34
|
+
</DropdownMenuTrigger>
|
|
35
|
+
<DropdownMenuContent>
|
|
36
|
+
<Show when={props.copyPageEnabled}>
|
|
37
|
+
<DropdownMenuItem onClick={props.onCopyPage}>
|
|
38
|
+
<FileText class="mr-2 size-4"/>
|
|
39
|
+
{siteLocale.t("actions.copyPage")}
|
|
40
|
+
</DropdownMenuItem>
|
|
41
|
+
</Show>
|
|
42
|
+
<Show when={props.copyMarkdownEnabled}>
|
|
43
|
+
<DropdownMenuItem onClick={props.onCopyMarkdown}>
|
|
44
|
+
<Copy class="mr-2 size-4"/>
|
|
45
|
+
{siteLocale.t("actions.copyAsMarkdown")}
|
|
46
|
+
</DropdownMenuItem>
|
|
47
|
+
</Show>
|
|
48
|
+
<Show when={props.aiProviders.length > 0}>
|
|
49
|
+
<For each={props.aiProviders}>
|
|
50
|
+
{(provider) => (<DropdownMenuItem as="a" href={providerUrl(provider)} target="_blank" rel="noreferrer">
|
|
51
|
+
<ExternalLink class="mr-2 size-4"/>
|
|
52
|
+
{siteLocale.t("actions.openInProvider", { provider: provider.name })}
|
|
53
|
+
</DropdownMenuItem>)}
|
|
54
|
+
</For>
|
|
55
|
+
</Show>
|
|
56
|
+
</DropdownMenuContent>
|
|
57
|
+
</DropdownMenu>
|
|
58
|
+
</Show>
|
|
59
|
+
</div>);
|
|
60
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Component } from "solid-js";
|
|
2
|
+
import { type PageActionsProps } from "./page-actions.jsx";
|
|
3
|
+
export interface PageHeaderProps extends PageActionsProps {
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const PageHeader: Component<PageHeaderProps>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SectionHeading } from "@/components/ui/section-heading";
|
|
2
|
+
import { PageActions } from "./page-actions.jsx";
|
|
3
|
+
export const PageHeader = (props) => (<SectionHeading variant="page" title={props.title} description={props.description} class="mb-8" actions={<PageActions sourceUrl={props.sourceUrl} pageActions={props.pageActions} aiProviders={props.aiProviders} copyPageEnabled={props.copyPageEnabled} copyMarkdownEnabled={props.copyMarkdownEnabled} pageUrl={props.pageUrl} pageTitle={props.pageTitle} markdown={props.markdown} onCopyPage={props.onCopyPage} onCopyMarkdown={props.onCopyMarkdown}/>}/>);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SidebarFooter as UiSidebarFooter, SidebarMenuButton } from "@/components/ui/sidebar";
|
|
2
|
+
export const SidebarFooter = (props) => (<UiSidebarFooter class="p-2">
|
|
3
|
+
<SidebarMenuButton size="lg" class="w-full justify-start">
|
|
4
|
+
<div class="flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/15 text-xs font-bold text-primary">
|
|
5
|
+
N
|
|
6
|
+
</div>
|
|
7
|
+
<div class="flex min-w-0 flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
|
|
8
|
+
<span class="truncate text-xs font-semibold">{props.brandText}</span>
|
|
9
|
+
<span class="truncate text-[10px] text-muted-foreground">{props.footerText}</span>
|
|
10
|
+
</div>
|
|
11
|
+
</SidebarMenuButton>
|
|
12
|
+
</UiSidebarFooter>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Component } from "solid-js";
|
|
2
|
+
import type { DocsConfig } from "../../../types.js";
|
|
3
|
+
export interface SidebarHeaderProps {
|
|
4
|
+
logo?: DocsConfig["logo"];
|
|
5
|
+
brandText: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const SidebarHeader: Component<SidebarHeaderProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Show } 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
|
+
export const SidebarHeader = (props) => (<UiSidebarHeader class="h-14 box-border p-3 group-data-[collapsible=icon]:p-2">
|
|
6
|
+
<SidebarMenuButton href={props.logo?.href || "/"} class={cn("h-8 w-full justify-between group-data-[collapsible=icon]:h-10")}>
|
|
7
|
+
<div class="flex items-center gap-2.5 overflow-hidden">
|
|
8
|
+
<Show when={props.logo?.image} fallback={<Logo class="h-7 w-auto"/>}>
|
|
9
|
+
{(image) => <img src={image()} alt={props.brandText} class="size-7 shrink-0 rounded-md object-contain"/>}
|
|
10
|
+
</Show>
|
|
11
|
+
<div class="flex min-w-0 flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
|
|
12
|
+
<span class="truncate text-xs font-bold">{props.brandText}</span>
|
|
13
|
+
<span class="truncate text-[10px] text-muted-foreground">{props.subtitle}</span>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</SidebarMenuButton>
|
|
17
|
+
</UiSidebarHeader>);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { For } from "solid-js";
|
|
2
|
+
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar";
|
|
3
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
4
|
+
export const SidebarMobileNav = (props) => {
|
|
5
|
+
const siteLocale = useSiteLocale();
|
|
6
|
+
return (<nav aria-label={siteLocale.t("navigation.primary")} class="border-b border-border/60 px-2 py-2 md:hidden">
|
|
7
|
+
<SidebarMenu>
|
|
8
|
+
<For each={props.items}>
|
|
9
|
+
{(item) => (<SidebarMenuItem>
|
|
10
|
+
<SidebarMenuButton href={item.href} onClick={props.onNavigate} class="w-full justify-start text-sm font-normal">
|
|
11
|
+
{item.title}
|
|
12
|
+
</SidebarMenuButton>
|
|
13
|
+
</SidebarMenuItem>)}
|
|
14
|
+
</For>
|
|
15
|
+
</SidebarMenu>
|
|
16
|
+
</nav>);
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DocsNavigationConfig } from "../../../types.js";
|
|
2
|
+
import type { Component } from "solid-js";
|
|
3
|
+
type SidebarPromoData = NonNullable<NonNullable<DocsNavigationConfig["sidebar"]>["promo"]>;
|
|
4
|
+
export interface SidebarPromoProps {
|
|
5
|
+
promo: SidebarPromoData;
|
|
6
|
+
}
|
|
7
|
+
export declare const SidebarPromo: Component<SidebarPromoProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export const SidebarPromo = (props) => {
|
|
7
|
+
const siteLocale = useSiteLocale();
|
|
8
|
+
return (<Card class="border-primary/30 bg-primary/5 shadow-none">
|
|
9
|
+
<CardContent class="p-4">
|
|
10
|
+
<CardTitle class="text-sm">{props.promo.title}</CardTitle>
|
|
11
|
+
<CardDescription class="mt-2 text-xs leading-relaxed">
|
|
12
|
+
{props.promo.description}
|
|
13
|
+
</CardDescription>
|
|
14
|
+
<a href={props.promo.href} target="_blank" rel="noreferrer" class={cn(buttonVariants({ variant: "outline", size: "sm" }), "mt-4 h-8 w-full gap-1.5 text-xs")}>
|
|
15
|
+
{props.promo.cta || siteLocale.t("actions.learnMore")}
|
|
16
|
+
<ExternalLink class="size-3" aria-hidden="true"/>
|
|
17
|
+
</a>
|
|
18
|
+
</CardContent>
|
|
19
|
+
</Card>);
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createClipboard } from "@/hooks/create-clipboard";
|
|
2
|
+
import { pageToMarkdown, pageToText, sourceToMarkdown } from "../../../client/page-actions.js";
|
|
3
|
+
function pageElement() {
|
|
4
|
+
if (typeof document === "undefined")
|
|
5
|
+
return null;
|
|
6
|
+
return document.querySelector("main article [data-docs-page-content]");
|
|
7
|
+
}
|
|
8
|
+
export function createPageCopy(sourceContent) {
|
|
9
|
+
const clipboard = createClipboard();
|
|
10
|
+
const markdown = () => {
|
|
11
|
+
const source = sourceContent();
|
|
12
|
+
const page = pageElement();
|
|
13
|
+
return source ? sourceToMarkdown(source) : page ? pageToMarkdown(page) : "";
|
|
14
|
+
};
|
|
15
|
+
const copyPage = async () => {
|
|
16
|
+
const page = pageElement();
|
|
17
|
+
if (page)
|
|
18
|
+
await clipboard.copy(pageToText(page));
|
|
19
|
+
};
|
|
20
|
+
const copyMarkdown = async () => {
|
|
21
|
+
const content = markdown();
|
|
22
|
+
if (content)
|
|
23
|
+
await clipboard.copy(content);
|
|
24
|
+
};
|
|
25
|
+
return { markdown, copyPage, copyMarkdown };
|
|
26
|
+
}
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
// packages/docs/src/themes/default/layout.tsx
|
|
2
|
-
import { createSignal,
|
|
2
|
+
import { createSignal, Show, splitProps } from "solid-js";
|
|
3
3
|
import { SidebarProvider } from "@/components/ui/sidebar";
|
|
4
4
|
import { SidebarInset } from "@/components/ui/sidebar";
|
|
5
|
-
import { Container } from "@/components/ui/container";
|
|
6
|
-
import { SectionHeading } from "@/components/ui/section-heading";
|
|
7
5
|
import { DocsNavbar } from "./navbar.jsx";
|
|
8
6
|
import { DocsSidebar } from "./sidebar.jsx";
|
|
9
|
-
import { DocsBreadcrumbs } from "./content/breadcrumbs.jsx";
|
|
10
|
-
import { DocsPager } from "./content/pager.jsx";
|
|
11
|
-
import { DocsTableOfContents } from "./content/table-of-contents.jsx";
|
|
12
|
-
import { DocsMobileTableOfContents } from "./navigation/mobile-table-of-contents.jsx";
|
|
13
7
|
import { DocsSearchDialog } from "./overlays/search-dialog.jsx";
|
|
14
8
|
import { cn } from "@/lib/cn";
|
|
15
|
-
import { buttonVariants } from "@/components/ui/button";
|
|
16
|
-
import { Button } from "@/components/ui/button";
|
|
17
|
-
import { Card, CardContent, CardDescription, CardTitle } from "@/components/ui/card";
|
|
18
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
19
|
-
import { createClipboard } from "@/hooks/create-clipboard";
|
|
20
|
-
import { Copy, FileText, ChevronDown, ExternalLink } from "lucide-solid";
|
|
21
|
-
import { pageToMarkdown, pageToText, resolvePageActionUrl, sourceToMarkdown } from "../../client/page-actions.js";
|
|
22
9
|
import { getRepositorySourceUrl } from "../../navigation/repository-links.js";
|
|
23
10
|
import { resolveSearchProvider } from "../../search/provider.js";
|
|
24
|
-
import {
|
|
11
|
+
import { DocsPageBody } from "./components/docs-page-body.jsx";
|
|
12
|
+
import { DocsLandingBody } from "./components/docs-landing-body.jsx";
|
|
13
|
+
import { PageHeader } from "./components/page-header.jsx";
|
|
14
|
+
import { createPageCopy } from "./hooks/use-page-copy.js";
|
|
15
|
+
import { isLandingPage, shouldShowLandingSidebar, shouldShowNavbar, shouldShowSidebarFooter, shouldShowSidebarHeader, shouldShowToc, shouldUseSidebarLayout, } from "./lib/layout-visibility.js";
|
|
25
16
|
export const DocsLayout = (props) => {
|
|
26
17
|
const [local, rest] = splitProps(props, [
|
|
27
18
|
"config",
|
|
@@ -38,21 +29,17 @@ export const DocsLayout = (props) => {
|
|
|
38
29
|
"class",
|
|
39
30
|
]);
|
|
40
31
|
const [searchOpen, setSearchOpen] = createSignal(false);
|
|
41
|
-
const
|
|
42
|
-
const pageClipboard = createClipboard();
|
|
32
|
+
const pageCopy = createPageCopy(() => local.sourceContent);
|
|
43
33
|
const searchEnabled = () => local.config.search?.enabled !== false;
|
|
44
34
|
const searchProvider = () => resolveSearchProvider(local.config.search);
|
|
45
35
|
const currentUrl = () => local.currentPage?.url;
|
|
46
|
-
const landingPage = () => local.currentPage
|
|
47
|
-
const showLandingSidebar = () => local.config
|
|
48
|
-
const showNavbar = () => local.config
|
|
49
|
-
const showToc = () =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const sidebarLayout = () => local.config.navigation?.layout !== "top";
|
|
54
|
-
const sidebarHeader = () => local.config.navigation?.sidebar?.header !== false;
|
|
55
|
-
const sidebarFooter = () => local.config.navigation?.sidebar?.footer !== false;
|
|
36
|
+
const landingPage = () => isLandingPage(local.currentPage, local.config);
|
|
37
|
+
const showLandingSidebar = () => shouldShowLandingSidebar(local.config);
|
|
38
|
+
const showNavbar = () => shouldShowNavbar(local.config);
|
|
39
|
+
const showToc = () => shouldShowToc(local.toc, local.currentPage, local.config, landingPage());
|
|
40
|
+
const sidebarLayout = () => shouldUseSidebarLayout(local.config);
|
|
41
|
+
const sidebarHeader = () => shouldShowSidebarHeader(local.config);
|
|
42
|
+
const sidebarFooter = () => shouldShowSidebarFooter(local.config);
|
|
56
43
|
const sidebarPromo = () => local.config.navigation?.sidebar?.promo;
|
|
57
44
|
const sourceUrl = () => {
|
|
58
45
|
const page = local.currentPage;
|
|
@@ -61,135 +48,24 @@ export const DocsLayout = (props) => {
|
|
|
61
48
|
return undefined;
|
|
62
49
|
return getRepositorySourceUrl(repository, page.sourcePath, local.config.contentDir || "docs");
|
|
63
50
|
};
|
|
64
|
-
const
|
|
65
|
-
? document.querySelector("main article [data-docs-page-content]")
|
|
66
|
-
: null;
|
|
67
|
-
const markdown = () => local.sourceContent
|
|
68
|
-
? sourceToMarkdown(local.sourceContent)
|
|
69
|
-
: pageElement() ? pageToMarkdown(pageElement()) : "";
|
|
70
|
-
const copyPage = async () => {
|
|
71
|
-
const page = pageElement();
|
|
72
|
-
if (page)
|
|
73
|
-
await pageClipboard.copy(pageToText(page));
|
|
74
|
-
};
|
|
75
|
-
const copyMarkdown = async () => {
|
|
76
|
-
const content = markdown();
|
|
77
|
-
if (content)
|
|
78
|
-
await pageClipboard.copy(content);
|
|
79
|
-
};
|
|
51
|
+
const markdown = pageCopy.markdown;
|
|
80
52
|
const aiProviders = () => local.config.pageActions?.ai || [];
|
|
81
53
|
const copyPageEnabled = () => local.config.pageActions?.copyPage !== false;
|
|
82
54
|
const copyMarkdownEnabled = () => local.config.pageActions?.copyMarkdown !== false;
|
|
83
|
-
const hasPageActions = () => copyPageEnabled() || copyMarkdownEnabled() || aiProviders().length > 0;
|
|
84
|
-
const pageActionUrl = (provider) => resolvePageActionUrl(provider.url, {
|
|
85
|
-
url: typeof window !== "undefined" ? window.location.href : "",
|
|
86
|
-
content: markdown(),
|
|
87
|
-
title: local.currentPage?.title,
|
|
88
|
-
prompt: provider.prompt,
|
|
89
|
-
});
|
|
90
55
|
const pageActions = () => local.currentPage?.pageActions || [];
|
|
91
56
|
const sidebar = (className) => (<DocsSidebar tree={local.tree} pages={local.pages} nav={local.config.navigation?.navbar || local.config.nav} currentUrl={currentUrl()} title={local.config.title} logo={local.config.logo} headerSubtitle={local.config.navigation?.sidebar?.headerSubtitle} footerText={local.config.navigation?.sidebar?.footerText} showHeader={sidebarHeader()} showFooter={sidebarFooter()} class={className}/>);
|
|
92
57
|
const content = () => (<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<Show when={local.currentPage?.title}>
|
|
99
|
-
<SectionHeading variant="page" title={local.currentPage.title} description={local.currentPage?.description} class="mb-8" actions={<div class="flex items-center gap-2">
|
|
100
|
-
<Show when={sourceUrl()}>
|
|
101
|
-
{(url) => (<a href={url()} target="_blank" rel="noreferrer" class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}>
|
|
102
|
-
{siteLocale.t("actions.viewSource")}
|
|
103
|
-
</a>)}
|
|
104
|
-
</Show>
|
|
105
|
-
<For each={pageActions()}>
|
|
106
|
-
{(action) => (<a href={action.href} target={action.external ? "_blank" : undefined} rel={action.external ? "noreferrer" : undefined} class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}>
|
|
107
|
-
{action.label}
|
|
108
|
-
</a>)}
|
|
109
|
-
</For>
|
|
110
|
-
<Show when={hasPageActions()}>
|
|
111
|
-
<DropdownMenu placement="bottom-end">
|
|
112
|
-
<DropdownMenuTrigger as={Button} variant="secondary" size="sm" class="shrink-0 gap-1" aria-label={siteLocale.t("actions.copyDocumentationPage")}>
|
|
113
|
-
<Copy class="size-3.5"/>
|
|
114
|
-
<span class="hidden sm:inline">{siteLocale.t("actions.copyPage")}</span>
|
|
115
|
-
<ChevronDown class="size-3.5"/>
|
|
116
|
-
</DropdownMenuTrigger>
|
|
117
|
-
<DropdownMenuContent>
|
|
118
|
-
<Show when={copyPageEnabled()}>
|
|
119
|
-
<DropdownMenuItem onClick={copyPage}>
|
|
120
|
-
<FileText class="mr-2 size-4"/>
|
|
121
|
-
{siteLocale.t("actions.copyPage")}
|
|
122
|
-
</DropdownMenuItem>
|
|
123
|
-
</Show>
|
|
124
|
-
<Show when={copyMarkdownEnabled()}>
|
|
125
|
-
<DropdownMenuItem onClick={copyMarkdown}>
|
|
126
|
-
<Copy class="mr-2 size-4"/>
|
|
127
|
-
{siteLocale.t("actions.copyAsMarkdown")}
|
|
128
|
-
</DropdownMenuItem>
|
|
129
|
-
</Show>
|
|
130
|
-
<Show when={aiProviders().length > 0}>
|
|
131
|
-
<For each={aiProviders()}>
|
|
132
|
-
{(provider) => (<DropdownMenuItem as="a" href={pageActionUrl(provider)} target="_blank" rel="noreferrer">
|
|
133
|
-
<ExternalLink class="mr-2 size-4"/>
|
|
134
|
-
{siteLocale.t("actions.openInProvider", { provider: provider.name })}
|
|
135
|
-
</DropdownMenuItem>)}
|
|
136
|
-
</For>
|
|
137
|
-
</Show>
|
|
138
|
-
</DropdownMenuContent>
|
|
139
|
-
</DropdownMenu>
|
|
140
|
-
</Show>
|
|
141
|
-
</div>}/>
|
|
142
|
-
</Show>
|
|
143
|
-
<Show when={showToc()}>
|
|
144
|
-
<DocsMobileTableOfContents items={local.toc} class="mb-6"/>
|
|
145
|
-
</Show>
|
|
146
|
-
<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>
|
|
147
|
-
{local.children}
|
|
148
|
-
</Container>
|
|
149
|
-
<Show when={local.prev || local.next}>
|
|
150
|
-
<DocsPager prev={local.prev} next={local.next}/>
|
|
151
|
-
</Show>
|
|
152
|
-
</Container>
|
|
153
|
-
<Show when={showToc() && local.currentPage?.url} keyed>
|
|
154
|
-
<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">
|
|
155
|
-
<div class="flex flex-col gap-5">
|
|
156
|
-
<DocsTableOfContents items={local.toc} class="max-h-none"/>
|
|
157
|
-
<Show when={sidebarPromo()}>
|
|
158
|
-
{(promo) => (<Card class="border-primary/30 bg-primary/5 shadow-none">
|
|
159
|
-
<CardContent class="p-4">
|
|
160
|
-
<CardTitle class="text-sm">{promo().title}</CardTitle>
|
|
161
|
-
<CardDescription class="mt-2 text-xs leading-relaxed">
|
|
162
|
-
{promo().description}
|
|
163
|
-
</CardDescription>
|
|
164
|
-
<a href={promo().href} target="_blank" rel="noreferrer" class={cn(buttonVariants({ variant: "outline", size: "sm" }), "mt-4 h-8 w-full gap-1.5 text-xs")}>
|
|
165
|
-
{promo().cta || siteLocale.t("actions.learnMore")}
|
|
166
|
-
<ExternalLink class="size-3" aria-hidden="true"/>
|
|
167
|
-
</a>
|
|
168
|
-
</CardContent>
|
|
169
|
-
</Card>)}
|
|
170
|
-
</Show>
|
|
171
|
-
</div>
|
|
172
|
-
</Container>
|
|
173
|
-
</Show>
|
|
174
|
-
</Container>
|
|
58
|
+
<DocsPageBody breadcrumbs={local.breadcrumbs} currentPage={local.currentPage} toc={local.toc} prev={local.prev} next={local.next} showToc={showToc()} sidebarPromo={sidebarPromo()} pageActions={<Show when={local.currentPage?.title}>
|
|
59
|
+
<PageHeader title={local.currentPage.title} description={local.currentPage?.description} sourceUrl={sourceUrl()} pageActions={pageActions()} aiProviders={aiProviders()} copyPageEnabled={copyPageEnabled()} copyMarkdownEnabled={copyMarkdownEnabled()} pageUrl={local.currentPage?.url} pageTitle={local.currentPage?.title} markdown={markdown} onCopyPage={pageCopy.copyPage} onCopyMarkdown={pageCopy.copyMarkdown}/>
|
|
60
|
+
</Show>}>
|
|
61
|
+
{local.children}
|
|
62
|
+
</DocsPageBody>
|
|
175
63
|
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined}/>
|
|
176
64
|
</SidebarInset>);
|
|
177
65
|
const landingContent = () => (<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
178
|
-
<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
<Show when={local.breadcrumbs && local.breadcrumbs.length > 0}>
|
|
182
|
-
<DocsBreadcrumbs items={local.breadcrumbs} class="mb-6"/>
|
|
183
|
-
</Show>
|
|
184
|
-
</Show>
|
|
185
|
-
<Container as="div" size="full" class="prose prose-zinc dark:prose-invert max-w-none px-0" data-docs-page-content>
|
|
186
|
-
{local.children}
|
|
187
|
-
</Container>
|
|
188
|
-
<Show when={local.config.home?.showPager === true && (local.prev || local.next)}>
|
|
189
|
-
<DocsPager prev={local.prev} next={local.next}/>
|
|
190
|
-
</Show>
|
|
191
|
-
</Container>
|
|
192
|
-
</Container>
|
|
66
|
+
<DocsLandingBody breadcrumbs={local.breadcrumbs} showBreadcrumbs={local.config.home?.showBreadcrumbs === true} showPager={local.config.home?.showPager === true} prev={local.prev} next={local.next}>
|
|
67
|
+
{local.children}
|
|
68
|
+
</DocsLandingBody>
|
|
193
69
|
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined}/>
|
|
194
70
|
</SidebarInset>);
|
|
195
71
|
return (<SidebarProvider defaultOpen={true} class="min-h-screen w-full items-stretch">
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DocsConfig, PageData, TocItem } from "../../../types.js";
|
|
2
|
+
export declare function isLandingPage(page: PageData | undefined, config: DocsConfig): boolean;
|
|
3
|
+
export declare function shouldShowLandingSidebar(config: DocsConfig): boolean;
|
|
4
|
+
export declare function shouldShowNavbar(config: DocsConfig): boolean;
|
|
5
|
+
export declare function shouldShowToc(toc: TocItem[] | undefined, page: PageData | undefined, config: DocsConfig, landingPage: boolean): boolean;
|
|
6
|
+
export declare function shouldUseSidebarLayout(config: DocsConfig): boolean;
|
|
7
|
+
export declare function shouldShowSidebarHeader(config: DocsConfig): boolean;
|
|
8
|
+
export declare function shouldShowSidebarFooter(config: DocsConfig): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function isLandingPage(page, config) {
|
|
2
|
+
return page?.url === "/" && config.home?.layout === "landing";
|
|
3
|
+
}
|
|
4
|
+
export function shouldShowLandingSidebar(config) {
|
|
5
|
+
return config.home?.showSidebar === true;
|
|
6
|
+
}
|
|
7
|
+
export function shouldShowNavbar(config) {
|
|
8
|
+
return config.home?.showNavbar !== false;
|
|
9
|
+
}
|
|
10
|
+
export function shouldShowToc(toc, page, config, landingPage) {
|
|
11
|
+
return Boolean(toc &&
|
|
12
|
+
toc.length > 0 &&
|
|
13
|
+
page?.frontmatter?.toc !== false &&
|
|
14
|
+
(!landingPage || config.home?.showToc === true));
|
|
15
|
+
}
|
|
16
|
+
export function shouldUseSidebarLayout(config) {
|
|
17
|
+
return config.navigation?.layout !== "top";
|
|
18
|
+
}
|
|
19
|
+
export function shouldShowSidebarHeader(config) {
|
|
20
|
+
return config.navigation?.sidebar?.header !== false;
|
|
21
|
+
}
|
|
22
|
+
export function shouldShowSidebarFooter(config) {
|
|
23
|
+
return config.navigation?.sidebar?.footer !== false;
|
|
24
|
+
}
|
|
@@ -27,12 +27,12 @@ export const DocsMobileTableOfContents = (props) => {
|
|
|
27
27
|
document.addEventListener("pointerdown", handlePointerDown);
|
|
28
28
|
onCleanup(() => document.removeEventListener("pointerdown", handlePointerDown));
|
|
29
29
|
});
|
|
30
|
-
return (<Collapsible open={open()} onOpenChange={setOpen} ref={setRootElement} class={cn("
|
|
30
|
+
return (<Collapsible open={open()} onOpenChange={setOpen} ref={setRootElement} class={cn("z-20 xl:hidden sticky top-16 rounded-md border border-border bg-background/95 shadow-sm backdrop-blur supports-backdrop-filter:bg-background/80", local.class)}>
|
|
31
31
|
<CollapsibleTrigger type="button" aria-label={title()} class="flex min-h-10 items-center justify-between rounded-md px-3 py-2 text-sm font-medium text-foreground">
|
|
32
32
|
<span class="truncate text-left">{activeTitle()}</span>
|
|
33
33
|
<ChevronDown class={cn("size-4 text-muted-foreground transition-transform", open() && "rotate-180")}/>
|
|
34
34
|
</CollapsibleTrigger>
|
|
35
|
-
<CollapsibleContent onClick={() => setOpen(false)} class="absolute inset-x-0 top-full z-30 max-h-[min(60vh,24rem)] rounded-b-md border border-t-0 border-border bg-card px-3 py-2 shadow-lg
|
|
35
|
+
<CollapsibleContent onClick={() => setOpen(false)} class="absolute inset-x-0 top-full z-30 max-h-[min(60vh,24rem)] rounded-b-md border border-t-0 border-border bg-card px-3 py-2 shadow-lg overflow-y-auto!">
|
|
36
36
|
<DocsTableOfContents items={local.items} title={title()} onActiveChange={handleActiveChange} class="max-h-56 overflow-y-auto" {...rest}/>
|
|
37
37
|
</CollapsibleContent>
|
|
38
38
|
</Collapsible>);
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
// packages/docs/src/themes/default/sidebar.tsx
|
|
2
|
-
import { createSignal,
|
|
2
|
+
import { createSignal, onCleanup, onMount, Show, splitProps } from "solid-js";
|
|
3
3
|
import { Sidebar } from "@/components/ui/sidebar";
|
|
4
|
-
import { SidebarHeader } from "@/components/ui/sidebar";
|
|
5
4
|
import { SidebarContent } from "@/components/ui/sidebar";
|
|
6
|
-
import { SidebarFooter } from "@/components/ui/sidebar";
|
|
7
|
-
import { SidebarMenuButton } from "@/components/ui/sidebar";
|
|
8
|
-
import { sidebarMenuButtonVariants } from "@/components/ui/sidebar";
|
|
9
5
|
import { useSidebar } from "@/components/ui/sidebar";
|
|
10
|
-
import { Logo } from "@/components/ui/logo";
|
|
11
6
|
import { createFocusTrap } from "@/hooks/create-focus-trap";
|
|
12
7
|
import { createLockScroll } from "@/hooks/create-lock-scroll";
|
|
13
8
|
import { cn } from "@/lib/cn";
|
|
9
|
+
import { SidebarFooter } from "./components/sidebar-footer.jsx";
|
|
10
|
+
import { SidebarHeader } from "./components/sidebar-header.jsx";
|
|
11
|
+
import { SidebarMobileNav } from "./components/sidebar-mobile-nav.jsx";
|
|
14
12
|
import { SidebarTree } from "./navigation/sidebar-tree.jsx";
|
|
15
13
|
import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
|
|
16
14
|
export const DocsSidebar = (props) => {
|
|
@@ -42,50 +40,22 @@ export const DocsSidebar = (props) => {
|
|
|
42
40
|
<button type="button" aria-label={siteLocale.t("navigation.closeSidebar")} class="fixed inset-0 z-40 cursor-default bg-black/50 md:hidden" onClick={() => sidebar.setOpenMobile(false)}/>
|
|
43
41
|
</Show>
|
|
44
42
|
<Show when={!sidebar.isMobile() || sidebar.openMobile()}>
|
|
45
|
-
<div class={cn("w-0 md:shrink-0", sidebar.open() ? "md:w-
|
|
43
|
+
<div class={cn("w-0 md:shrink-0", sidebar.open() ? "md:w-(--sidebar-width)" : "md:w-(--sidebar-width-icon)")}>
|
|
46
44
|
<Sidebar ref={setSidebarElement} collapsible={sidebar.isMobile() ? "none" : "icon"} class={cn("top-0 self-start z-30 h-screen shrink-0 rounded-none border-y-0 border-l-0 border-r border-border bg-card shadow-sm md:fixed md:inset-y-0 md:left-0", "overflow-hidden max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:z-50 max-md:w-[min(17rem,calc(100vw-1rem))] max-md:shadow-xl", local.class)} {...rest}>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<div class="flex items-center gap-2.5 overflow-hidden">
|
|
51
|
-
<Show when={local.logo?.image} fallback={<Logo class="h-7 w-auto"/>}>
|
|
52
|
-
{(image) => <img src={image()} alt={brandText()} class="size-7 shrink-0 rounded-md object-contain"/>}
|
|
53
|
-
</Show>
|
|
54
|
-
<div class="flex min-w-0 flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
|
|
55
|
-
<span class="truncate text-xs font-bold">{brandText()}</span>
|
|
56
|
-
<span class="truncate text-[10px] text-muted-foreground">{local.headerSubtitle}</span>
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
</a>
|
|
60
|
-
</SidebarHeader>
|
|
61
|
-
</Show>
|
|
45
|
+
<Show when={local.showHeader !== false}>
|
|
46
|
+
<SidebarHeader logo={local.logo} brandText={brandText()} subtitle={local.headerSubtitle}/>
|
|
47
|
+
</Show>
|
|
62
48
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</a>)}
|
|
70
|
-
</For>
|
|
71
|
-
</nav>
|
|
72
|
-
</Show>
|
|
73
|
-
<SidebarTree tree={local.tree} pages={local.pages} currentUrl={local.currentUrl}/>
|
|
74
|
-
</SidebarContent>
|
|
49
|
+
<SidebarContent class="h-full overflow-y-auto scrollbar-none [&::-webkit-scrollbar]:hidden">
|
|
50
|
+
<Show when={local.nav?.length}>
|
|
51
|
+
<SidebarMobileNav items={local.nav} onNavigate={() => sidebar.setOpenMobile(false)}/>
|
|
52
|
+
</Show>
|
|
53
|
+
<SidebarTree tree={local.tree} pages={local.pages} currentUrl={local.currentUrl}/>
|
|
54
|
+
</SidebarContent>
|
|
75
55
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<div class="flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/15 text-xs font-bold text-primary">
|
|
80
|
-
N
|
|
81
|
-
</div>
|
|
82
|
-
<div class="flex min-w-0 flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
|
|
83
|
-
<span class="truncate text-xs font-semibold">{brandText()}</span>
|
|
84
|
-
<span class="truncate text-[10px] text-muted-foreground">{local.footerText}</span>
|
|
85
|
-
</div>
|
|
86
|
-
</SidebarMenuButton>
|
|
87
|
-
</SidebarFooter>
|
|
88
|
-
</Show>
|
|
56
|
+
<Show when={local.showFooter !== false}>
|
|
57
|
+
<SidebarFooter brandText={brandText()} footerText={local.footerText}/>
|
|
58
|
+
</Show>
|
|
89
59
|
</Sidebar>
|
|
90
60
|
</div>
|
|
91
61
|
</Show>
|
package/dist/types.d.ts
CHANGED
|
@@ -113,7 +113,16 @@ export interface ShikiConfig {
|
|
|
113
113
|
light?: string;
|
|
114
114
|
dark?: string;
|
|
115
115
|
};
|
|
116
|
+
/** Allowlist of built-in language ids. Custom languages are not affected. */
|
|
116
117
|
langs?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Additional languages as Shiki language registrations (TextMate grammars
|
|
120
|
+
* with `name`, `scopeName`, `patterns` and optional `aliases`). Code fences
|
|
121
|
+
* whose language matches a `name` or alias use the grammar. Names and
|
|
122
|
+
* aliases must not collide with built-in languages or each other. Grammars
|
|
123
|
+
* must be plain JSON data and are loaded lazily.
|
|
124
|
+
*/
|
|
125
|
+
customLangs?: import("shiki").LanguageRegistration[];
|
|
117
126
|
}
|
|
118
127
|
export interface DocsSeoConfig {
|
|
119
128
|
/** Social preview image path or URL. */
|