@nikala-ui/folio 0.14.0 → 0.15.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.
Files changed (107) hide show
  1. package/README.md +16 -0
  2. package/dist/cli/commands/init.js +21 -2
  3. package/dist/client/app.jsx +6 -3
  4. package/dist/client/components/docs-layout-shell.d.ts +1 -0
  5. package/dist/client/components/docs-layout-shell.jsx +1 -1
  6. package/dist/client/components/docs-page-content.jsx +9 -5
  7. package/dist/client/navigation/page-navigation.js +10 -27
  8. package/dist/client/public/algolia-logo.svg +15 -0
  9. package/dist/client/public/favicon.ico +0 -0
  10. package/dist/client/public/logo.svg +11 -0
  11. package/dist/client/routing/use-docs-router.d.ts +1 -0
  12. package/dist/client/routing/use-docs-router.js +12 -3
  13. package/dist/client/style.css +139 -55
  14. package/dist/components/ui/api-table.jsx +6 -4
  15. package/dist/components/ui/code-block.jsx +6 -4
  16. package/dist/components/ui/command.jsx +9 -5
  17. package/dist/components/ui/list.jsx +3 -1
  18. package/dist/components/ui/logo.d.ts +4 -1
  19. package/dist/components/ui/logo.jsx +8 -22
  20. package/dist/components/ui/package-manager-tabs.jsx +4 -2
  21. package/dist/components/ui/pager.jsx +4 -2
  22. package/dist/components/ui/section-heading.jsx +1 -1
  23. package/dist/components/ui/sidebar.jsx +6 -3
  24. package/dist/components/ui/spinner.jsx +3 -1
  25. package/dist/components/ui/theme-toggle.jsx +14 -12
  26. package/dist/config.d.ts +1 -0
  27. package/dist/config.js +84 -29
  28. package/dist/core/content-scanner.d.ts +2 -1
  29. package/dist/core/content-scanner.js +2 -9
  30. package/dist/core/plugin/index.d.ts +2 -0
  31. package/dist/core/plugin/index.js +1 -0
  32. package/dist/core/plugin/lifecycle-error.d.ts +19 -0
  33. package/dist/core/plugin/lifecycle-error.js +28 -0
  34. package/dist/core/plugin/lifecycle-snapshot.d.ts +1 -0
  35. package/dist/core/plugin/lifecycle-snapshot.js +156 -0
  36. package/dist/core/plugin/lifecycle.d.ts +34 -0
  37. package/dist/core/plugin/lifecycle.js +170 -0
  38. package/dist/core/route-tree.d.ts +3 -2
  39. package/dist/core/route-tree.js +40 -10
  40. package/dist/index.d.ts +5 -3
  41. package/dist/index.js +3 -3
  42. package/dist/plugin.d.ts +60 -0
  43. package/dist/plugin.js +51 -0
  44. package/dist/plugins/i18n/components/site-language-switcher.d.ts +10 -0
  45. package/dist/plugins/i18n/components/site-language-switcher.jsx +39 -0
  46. package/dist/plugins/i18n/constants.d.ts +1 -0
  47. package/dist/plugins/i18n/constants.js +1 -0
  48. package/dist/plugins/i18n/index.d.ts +11 -0
  49. package/dist/plugins/i18n/index.js +89 -0
  50. package/dist/plugins/i18n/navigation.d.ts +5 -0
  51. package/dist/plugins/i18n/navigation.js +33 -0
  52. package/dist/plugins/i18n/runtime.d.ts +19 -0
  53. package/dist/plugins/i18n/runtime.jsx +65 -0
  54. package/dist/plugins/i18n/site-locale.d.ts +12 -0
  55. package/dist/plugins/i18n/site-locale.js +119 -0
  56. package/dist/server/index.d.ts +4 -1
  57. package/dist/server/index.js +69 -33
  58. package/dist/server/module-serialization.d.ts +6 -0
  59. package/dist/server/module-serialization.js +26 -0
  60. package/dist/server/plugin/components.d.ts +7 -0
  61. package/dist/server/plugin/components.js +82 -0
  62. package/dist/server/plugin/constants.d.ts +17 -0
  63. package/dist/server/plugin/constants.js +21 -0
  64. package/dist/server/{plugin.d.ts → plugin/index.d.ts} +3 -1
  65. package/dist/server/plugin/index.js +166 -0
  66. package/dist/server/plugin/lifecycle.d.ts +32 -0
  67. package/dist/server/plugin/lifecycle.js +110 -0
  68. package/dist/server/plugin/styles.d.ts +3 -0
  69. package/dist/server/plugin/styles.js +22 -0
  70. package/dist/server/plugin/virtual-modules.d.ts +11 -0
  71. package/dist/server/plugin/virtual-modules.js +88 -0
  72. package/dist/server/seo.d.ts +4 -0
  73. package/dist/server/seo.js +87 -0
  74. package/dist/themes/default/content/breadcrumbs.jsx +5 -2
  75. package/dist/themes/default/content/table-of-contents.jsx +3 -1
  76. package/dist/themes/default/layout.jsx +39 -12
  77. package/dist/themes/default/navbar.jsx +14 -7
  78. package/dist/themes/default/navigation/mobile-table-of-contents.jsx +3 -1
  79. package/dist/themes/default/navigation/sidebar-tree.d.ts +2 -0
  80. package/dist/themes/default/navigation/sidebar-tree.jsx +11 -2
  81. package/dist/themes/default/overlays/search-dialog.jsx +14 -3
  82. package/dist/themes/default/sidebar.jsx +7 -5
  83. package/dist/themes/types.d.ts +5 -0
  84. package/dist/types.d.ts +36 -0
  85. package/dist/utils/format-title.d.ts +1 -0
  86. package/dist/utils/format-title.js +11 -0
  87. package/dist/vendor/docs-src/components/ui/api-table.tsx +6 -4
  88. package/dist/vendor/docs-src/components/ui/code-block.tsx +6 -4
  89. package/dist/vendor/docs-src/components/ui/command.tsx +9 -5
  90. package/dist/vendor/docs-src/components/ui/list.tsx +4 -2
  91. package/dist/vendor/docs-src/components/ui/logo.tsx +19 -48
  92. package/dist/vendor/docs-src/components/ui/package-manager-tabs.tsx +4 -2
  93. package/dist/vendor/docs-src/components/ui/pager.tsx +4 -2
  94. package/dist/vendor/docs-src/components/ui/section-heading.tsx +5 -1
  95. package/dist/vendor/docs-src/components/ui/sidebar.tsx +7 -4
  96. package/dist/vendor/docs-src/components/ui/spinner.tsx +3 -1
  97. package/dist/vendor/docs-src/components/ui/theme-toggle.tsx +15 -13
  98. package/dist/vendor/docs-src/plugins/i18n/components/site-language-switcher.tsx +56 -0
  99. package/dist/vendor/docs-src/plugins/i18n/constants.ts +1 -0
  100. package/dist/vendor/docs-src/plugins/i18n/index.ts +110 -0
  101. package/dist/vendor/docs-src/plugins/i18n/navigation.ts +49 -0
  102. package/dist/vendor/docs-src/plugins/i18n/runtime.tsx +91 -0
  103. package/dist/vendor/docs-src/plugins/i18n/site-locale.ts +140 -0
  104. package/dist/version.d.ts +1 -1
  105. package/dist/version.js +1 -1
  106. package/package.json +11 -4
  107. package/dist/server/plugin.js +0 -521
@@ -0,0 +1,87 @@
1
+ function escapeHtml(value) {
2
+ return value
3
+ .replace(/&/g, "&")
4
+ .replace(/</g, "&lt;")
5
+ .replace(/>/g, "&gt;")
6
+ .replace(/"/g, "&quot;")
7
+ .replace(/'/g, "&#39;");
8
+ }
9
+ function absoluteUrl(siteUrl, value) {
10
+ try {
11
+ const url = new URL(value, siteUrl || "https://folio.invalid");
12
+ if (!siteUrl && url.origin === "https://folio.invalid")
13
+ return undefined;
14
+ return url.toString();
15
+ }
16
+ catch {
17
+ return undefined;
18
+ }
19
+ }
20
+ function jsonLd(value) {
21
+ return JSON.stringify(value).replace(/</g, "\\u003c");
22
+ }
23
+ export function renderSeoMetadata(config, page) {
24
+ const siteName = config.seo?.siteName || config.title || "Documentation";
25
+ const title = `${page.title} - ${config.title || "Documentation"}`;
26
+ const description = page.description || config.description || "";
27
+ const pageUrl = absoluteUrl(config.siteUrl, page.url);
28
+ const imageUrl = config.seo?.image
29
+ ? absoluteUrl(config.siteUrl, config.seo.image)
30
+ : undefined;
31
+ const tags = [
32
+ `<title>${escapeHtml(title)}</title>`,
33
+ ];
34
+ if (description) {
35
+ tags.push(`<meta name="description" content="${escapeHtml(description)}">`);
36
+ }
37
+ if (page.frontmatter.noindex === true) {
38
+ tags.push(`<meta name="robots" content="noindex, follow">`);
39
+ }
40
+ if (pageUrl) {
41
+ tags.push(`<link rel="canonical" href="${escapeHtml(pageUrl)}">`);
42
+ tags.push(`<meta property="og:url" content="${escapeHtml(pageUrl)}">`);
43
+ }
44
+ tags.push(`<meta property="og:type" content="article">`, `<meta property="og:title" content="${escapeHtml(title)}">`, `<meta property="og:site_name" content="${escapeHtml(siteName)}">`, `<meta property="og:locale" content="${escapeHtml(config.seo?.locale || "en_US")}">`, `<meta name="twitter:card" content="${config.seo?.twitterCard || "summary_large_image"}">`, `<meta name="twitter:title" content="${escapeHtml(title)}">`);
45
+ if (description) {
46
+ tags.push(`<meta property="og:description" content="${escapeHtml(description)}">`, `<meta name="twitter:description" content="${escapeHtml(description)}">`);
47
+ }
48
+ if (imageUrl) {
49
+ tags.push(`<meta property="og:image" content="${escapeHtml(imageUrl)}">`, `<meta name="twitter:image" content="${escapeHtml(imageUrl)}">`);
50
+ if (config.seo?.imageAlt) {
51
+ tags.push(`<meta property="og:image:alt" content="${escapeHtml(config.seo.imageAlt)}">`);
52
+ }
53
+ }
54
+ if (pageUrl) {
55
+ const structuredData = {
56
+ "@context": "https://schema.org",
57
+ "@graph": [
58
+ {
59
+ "@type": "TechArticle",
60
+ headline: page.title,
61
+ description: description || undefined,
62
+ url: pageUrl,
63
+ image: imageUrl,
64
+ isPartOf: { "@type": "WebSite", name: siteName, url: absoluteUrl(config.siteUrl, "/") },
65
+ },
66
+ {
67
+ "@type": "BreadcrumbList",
68
+ itemListElement: [
69
+ { "@type": "ListItem", position: 1, name: siteName, item: absoluteUrl(config.siteUrl, "/") },
70
+ { "@type": "ListItem", position: 2, name: page.title, item: pageUrl },
71
+ ],
72
+ },
73
+ ],
74
+ };
75
+ tags.push(`<script type="application/ld+json">${jsonLd(structuredData)}</script>`);
76
+ }
77
+ return tags.join("");
78
+ }
79
+ export function isPageIndexable(page) {
80
+ return page.frontmatter.noindex !== true;
81
+ }
82
+ export function getPageLastModified(page) {
83
+ const value = page.frontmatter.updatedAt;
84
+ if (!value || Number.isNaN(Date.parse(value)))
85
+ return undefined;
86
+ return new Date(value).toISOString().slice(0, 10);
87
+ }
@@ -6,17 +6,20 @@ import { BreadcrumbItem } from "@/components/ui/breadcrumb";
6
6
  import { BreadcrumbLink } from "@/components/ui/breadcrumb";
7
7
  import { BreadcrumbSeparator } from "@/components/ui/breadcrumb";
8
8
  import { BreadcrumbPage } from "@/components/ui/breadcrumb";
9
+ import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
9
10
  export const DocsBreadcrumbs = (props) => {
10
11
  const [local, rest] = splitProps(props, ["items", "class"]);
12
+ const siteLocale = useSiteLocale();
11
13
  return (<Breadcrumb class={local.class} {...rest}>
12
14
  <BreadcrumbList>
13
15
  <For each={local.items}>
14
16
  {(item, index) => {
15
17
  const isLast = () => index() === local.items.length - 1;
18
+ const title = () => item.href === "/" ? siteLocale.t("navigation.documentation") : item.title;
16
19
  return (<>
17
20
  <BreadcrumbItem>
18
- <Show when={!isLast() && item.href} fallback={<BreadcrumbPage>{item.title}</BreadcrumbPage>}>
19
- <BreadcrumbLink href={item.href}>{item.title}</BreadcrumbLink>
21
+ <Show when={!isLast() && item.href} fallback={<BreadcrumbPage>{title()}</BreadcrumbPage>}>
22
+ <BreadcrumbLink href={item.href}>{title()}</BreadcrumbLink>
20
23
  </Show>
21
24
  </BreadcrumbItem>
22
25
  <Show when={!isLast()}>
@@ -1,9 +1,11 @@
1
1
  // packages/docs/src/themes/default/content/table-of-contents.tsx
2
2
  import { createSignal, onMount, Show, splitProps } from "solid-js";
3
3
  import { TableOfContents as CoreTableOfContents } from "@/components/ui/table-of-contents";
4
+ import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
4
5
  export const DocsTableOfContents = (props) => {
5
6
  const [local, rest] = splitProps(props, ["items", "title", "class"]);
6
7
  const [ready, setReady] = createSignal(false);
8
+ const siteLocale = useSiteLocale();
7
9
  onMount(() => {
8
10
  if (typeof window === "undefined") {
9
11
  setReady(true);
@@ -13,6 +15,6 @@ export const DocsTableOfContents = (props) => {
13
15
  return () => window.cancelAnimationFrame(frame);
14
16
  });
15
17
  return (<Show when={ready()}>
16
- <CoreTableOfContents items={local.items} title={local.title ?? "On this page"} class={local.class} {...rest}/>
18
+ <CoreTableOfContents items={local.items} title={local.title ?? siteLocale.t("tableOfContents.title")} class={local.class} {...rest}/>
17
19
  </Show>);
18
20
  };
@@ -14,18 +14,21 @@ import { DocsSearchDialog } from "./overlays/search-dialog.jsx";
14
14
  import { cn } from "@/lib/cn";
15
15
  import { buttonVariants } from "@/components/ui/button";
16
16
  import { Button } from "@/components/ui/button";
17
+ import { Card, CardContent, CardDescription, CardTitle } from "@/components/ui/card";
17
18
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
18
19
  import { createClipboard } from "@/hooks/create-clipboard";
19
20
  import { Copy, FileText, ChevronDown, ExternalLink } from "lucide-solid";
20
21
  import { pageToMarkdown, pageToText, resolvePageActionUrl, sourceToMarkdown } from "../../client/page-actions.js";
21
22
  import { getRepositorySourceUrl } from "../../navigation/repository-links.js";
22
23
  import { resolveSearchProvider } from "../../search/provider.js";
24
+ import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
23
25
  export const DocsLayout = (props) => {
24
26
  const [local, rest] = splitProps(props, [
25
27
  "config",
26
28
  "tree",
27
29
  "pages",
28
30
  "currentPage",
31
+ "onNavigate",
29
32
  "breadcrumbs",
30
33
  "toc",
31
34
  "prev",
@@ -35,6 +38,7 @@ export const DocsLayout = (props) => {
35
38
  "class",
36
39
  ]);
37
40
  const [searchOpen, setSearchOpen] = createSignal(false);
41
+ const siteLocale = useSiteLocale();
38
42
  const pageClipboard = createClipboard();
39
43
  const searchEnabled = () => local.config.search?.enabled !== false;
40
44
  const searchProvider = () => resolveSearchProvider(local.config.search);
@@ -49,6 +53,7 @@ export const DocsLayout = (props) => {
49
53
  const sidebarLayout = () => local.config.navigation?.layout !== "top";
50
54
  const sidebarHeader = () => local.config.navigation?.sidebar?.header !== false;
51
55
  const sidebarFooter = () => local.config.navigation?.sidebar?.footer !== false;
56
+ const sidebarPromo = () => local.config.navigation?.sidebar?.promo;
52
57
  const sourceUrl = () => {
53
58
  const page = local.currentPage;
54
59
  const repository = local.config.repository;
@@ -82,7 +87,8 @@ export const DocsLayout = (props) => {
82
87
  title: local.currentPage?.title,
83
88
  prompt: provider.prompt,
84
89
  });
85
- const sidebar = (className) => (<DocsSidebar tree={local.tree} 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}/>);
90
+ const pageActions = () => local.currentPage?.pageActions || [];
91
+ 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}/>);
86
92
  const content = () => (<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
87
93
  <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">
88
94
  <Container as="article" size="full" class="min-w-0 max-w-none mx-0 px-0 sm:px-4 w-full">
@@ -93,34 +99,39 @@ export const DocsLayout = (props) => {
93
99
  <SectionHeading variant="page" title={local.currentPage.title} description={local.currentPage?.description} class="mb-8" actions={<div class="flex items-center gap-2">
94
100
  <Show when={sourceUrl()}>
95
101
  {(url) => (<a href={url()} target="_blank" rel="noreferrer" class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}>
96
- View source
102
+ {siteLocale.t("actions.viewSource")}
97
103
  </a>)}
98
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>
99
110
  <Show when={hasPageActions()}>
100
111
  <DropdownMenu placement="bottom-end">
101
- <DropdownMenuTrigger as={Button} variant="secondary" size="sm" class="shrink-0 gap-1" aria-label="Copy documentation page">
112
+ <DropdownMenuTrigger as={Button} variant="secondary" size="sm" class="shrink-0 gap-1" aria-label={siteLocale.t("actions.copyDocumentationPage")}>
102
113
  <Copy class="size-3.5"/>
103
- <span class="hidden sm:inline">Copy page</span>
114
+ <span class="hidden sm:inline">{siteLocale.t("actions.copyPage")}</span>
104
115
  <ChevronDown class="size-3.5"/>
105
116
  </DropdownMenuTrigger>
106
117
  <DropdownMenuContent>
107
118
  <Show when={copyPageEnabled()}>
108
119
  <DropdownMenuItem onClick={copyPage}>
109
120
  <FileText class="mr-2 size-4"/>
110
- Copy page
121
+ {siteLocale.t("actions.copyPage")}
111
122
  </DropdownMenuItem>
112
123
  </Show>
113
124
  <Show when={copyMarkdownEnabled()}>
114
125
  <DropdownMenuItem onClick={copyMarkdown}>
115
126
  <Copy class="mr-2 size-4"/>
116
- Copy as Markdown
127
+ {siteLocale.t("actions.copyAsMarkdown")}
117
128
  </DropdownMenuItem>
118
129
  </Show>
119
130
  <Show when={aiProviders().length > 0}>
120
131
  <For each={aiProviders()}>
121
132
  {(provider) => (<DropdownMenuItem as="a" href={pageActionUrl(provider)} target="_blank" rel="noreferrer">
122
133
  <ExternalLink class="mr-2 size-4"/>
123
- Open in {provider.name}
134
+ {siteLocale.t("actions.openInProvider", { provider: provider.name })}
124
135
  </DropdownMenuItem>)}
125
136
  </For>
126
137
  </Show>
@@ -140,8 +151,24 @@ export const DocsLayout = (props) => {
140
151
  </Show>
141
152
  </Container>
142
153
  <Show when={showToc() && local.currentPage?.url} keyed>
143
- <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-hidden bg-background">
144
- <DocsTableOfContents items={local.toc} class="max-h-[calc(100vh-3.5rem)]"/>
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>
145
172
  </Container>
146
173
  </Show>
147
174
  </Container>
@@ -167,18 +194,18 @@ export const DocsLayout = (props) => {
167
194
  </SidebarInset>);
168
195
  return (<SidebarProvider defaultOpen={true} class="min-h-screen w-full items-stretch">
169
196
  <Show when={landingPage()} fallback={<Show when={sidebarLayout()} fallback={<div class="flex min-h-screen min-w-0 flex-1 flex-col">
170
- <DocsNavbar config={local.config} showBrand={true} showSidebarTrigger={false} onOpenSearch={() => setSearchOpen(true)}/>
197
+ <DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={true} showSidebarTrigger={false} onOpenSearch={() => setSearchOpen(true)}/>
171
198
  <div class="flex min-h-0 min-w-0 max-w-full flex-1 items-start">{content()}</div>
172
199
  </div>}>
173
200
  {sidebar()}
174
201
  <div class="flex min-h-screen min-w-0 flex-1 flex-col">
175
- <DocsNavbar config={local.config} showBrand={false} onOpenSearch={() => setSearchOpen(true)}/>
202
+ <DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={false} onOpenSearch={() => setSearchOpen(true)}/>
176
203
  {content()}
177
204
  </div>
178
205
  </Show>}>
179
206
  <div class="flex min-h-screen min-w-0 flex-1 flex-col">
180
207
  <Show when={showNavbar()}>
181
- <DocsNavbar config={local.config} showBrand={true} showSidebarTrigger={showLandingSidebar()} mobileSidebarTrigger={landingPage()} onOpenSearch={() => setSearchOpen(true)}/>
208
+ <DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={true} showSidebarTrigger={showLandingSidebar()} mobileSidebarTrigger={landingPage()} onOpenSearch={() => setSearchOpen(true)}/>
182
209
  </Show>
183
210
  <Show when={showLandingSidebar()} fallback={<>
184
211
  <Show when={landingPage()}>
@@ -10,14 +10,17 @@ import { buttonVariants } from "@/components/ui/button";
10
10
  import { Kbd } from "@/components/ui/kbd";
11
11
  import { SidebarTrigger } from "@/components/ui/sidebar";
12
12
  import { ThemeToggle } from "@/components/ui/theme-toggle";
13
+ import { DocsSiteLanguageSwitcher } from "../../plugins/i18n/components/site-language-switcher.jsx";
14
+ import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
13
15
  import { Logo } from "@/components/ui/logo";
14
16
  import { Search } from "lucide-solid";
15
17
  export const DocsNavbar = (props) => {
16
- const [local, rest] = splitProps(props, ["config", "onOpenSearch", "showBrand", "showSidebarTrigger", "mobileSidebarTrigger", "class"]);
18
+ const [local, rest] = splitProps(props, ["config", "currentPage", "pages", "onNavigate", "onOpenSearch", "showBrand", "showSidebarTrigger", "mobileSidebarTrigger", "class"]);
17
19
  const title = () => local.config.title || "Folio";
18
20
  const logoText = () => local.config.logo?.text || title();
19
21
  const logoHref = () => local.config.logo?.href || "/";
20
22
  const repoUrl = () => local.config.repository?.url;
23
+ const siteLocale = useSiteLocale();
21
24
  return (<Navbar variant="default" maxWidth="full" isSticky={true} class={local.class} {...rest}>
22
25
  <NavbarContainer class="h-14 md:h-14 px-4 sm:px-6">
23
26
  <NavbarContent justify="start" class="gap-3">
@@ -26,7 +29,7 @@ export const DocsNavbar = (props) => {
26
29
  </Show>
27
30
  <Show when={local.showBrand !== false}>
28
31
  <NavbarBrand href={logoHref()} class="text-base font-bold tracking-tight">
29
- <Show when={local.config.logo?.image} fallback={<Logo class="size-6"/>}>
32
+ <Show when={local.config.logo?.image} fallback={<Logo class="h-6 w-auto"/>}>
30
33
  {(img) => <img src={img()} alt={logoText()} class="size-6 object-contain"/>}
31
34
  </Show>
32
35
  <span>{logoText()}</span>
@@ -50,13 +53,13 @@ export const DocsNavbar = (props) => {
50
53
  <Show when={local.config.search?.enabled !== false && local.onOpenSearch}>
51
54
  <NavbarItem>
52
55
  <Button variant="outline" size="sm" onClick={() => local.onOpenSearch?.()} class="hidden sm:inline-flex text-muted-foreground w-48 sm:w-64 justify-between h-8 text-xs font-normal">
53
- <span class="inline-flex items-center gap-2">
54
- <Search class="size-3.5"/>
55
- <span>Search docs...</span>
56
+ <span class="inline-flex items-center gap-2">
57
+ <Search class="size-3.5"/>
58
+ <span>{siteLocale.t("navigation.search")}</span>
56
59
  </span>
57
60
  <Kbd size="sm">⌘K</Kbd>
58
61
  </Button>
59
- <Button variant="ghost" size="sm" onClick={() => local.onOpenSearch?.()} class="sm:hidden p-2" aria-label="Search docs">
62
+ <Button variant="ghost" size="sm" onClick={() => local.onOpenSearch?.()} class="sm:hidden p-2" aria-label={siteLocale.t("navigation.searchLabel")}>
60
63
  <Search class="size-4"/>
61
64
  </Button>
62
65
  </NavbarItem>
@@ -66,11 +69,15 @@ export const DocsNavbar = (props) => {
66
69
  <Show when={repoUrl()}>
67
70
  {(url) => (<NavbarItem>
68
71
  <a href={url()} target="_blank" rel="noreferrer" class={buttonVariants({ variant: "ghost", size: "sm" }) + " hidden sm:inline-flex h-8 px-2 text-xs"}>
69
- GitHub
72
+ {siteLocale.t("navigation.github")}
70
73
  </a>
71
74
  </NavbarItem>)}
72
75
  </Show>
73
76
 
77
+ <NavbarItem>
78
+ <DocsSiteLanguageSwitcher currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate}/>
79
+ </NavbarItem>
80
+
74
81
  {/* Theme Toggle */}
75
82
  <NavbarItem>
76
83
  <ThemeToggle />
@@ -5,12 +5,14 @@ import { CollapsibleTrigger } from "@/components/ui/collapsible";
5
5
  import { cn } from "@/lib/cn";
6
6
  import { ChevronDown } from "lucide-solid";
7
7
  import { DocsTableOfContents } from "../content/table-of-contents.jsx";
8
+ import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
8
9
  export const DocsMobileTableOfContents = (props) => {
9
10
  const [local, rest] = splitProps(props, ["items", "title", "class", "onActiveChange"]);
10
11
  const [open, setOpen] = createSignal(false);
11
12
  const [activeId, setActiveId] = createSignal(local.items[0]?.id || "");
12
13
  const [rootElement, setRootElement] = createSignal();
13
- const title = () => local.title ?? "On this page";
14
+ const siteLocale = useSiteLocale();
15
+ const title = () => local.title ?? siteLocale.t("tableOfContents.title");
14
16
  const activeTitle = () => local.items.find((item) => item.id === activeId())?.text || title();
15
17
  const handleActiveChange = (id) => {
16
18
  setActiveId(id);
@@ -1,7 +1,9 @@
1
1
  import { type Component } from "solid-js";
2
2
  import type { SidebarItem } from "../../../types.js";
3
+ import type { PageData } from "../../../types.js";
3
4
  export interface SidebarTreeProps {
4
5
  tree: SidebarItem[];
6
+ pages?: readonly PageData[];
5
7
  currentUrl?: string;
6
8
  }
7
9
  export declare const SidebarTree: Component<SidebarTreeProps>;
@@ -16,10 +16,19 @@ import { useSidebar } from "@/components/ui/sidebar";
16
16
  import { Button } from "@/components/ui/button";
17
17
  import { cn } from "@/lib/cn";
18
18
  import { ChevronRight, Folder } from "lucide-solid";
19
+ import { localizeSidebarTree } from "../../../plugins/i18n/navigation.js";
20
+ import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
19
21
  import { resolveDefaultIcon } from "../icons.js";
20
22
  import { containsActiveSidebarItem, containsNewSidebarItem, isSidebarItemActive, isSidebarItemNew, } from "../../../navigation/sidebar-state.js";
21
23
  export const SidebarTree = (props) => {
22
24
  const sidebar = useSidebar();
25
+ const siteLocale = useSiteLocale();
26
+ const activeLocale = () => {
27
+ const currentPage = props.pages?.find((page) => page.url === props.currentUrl);
28
+ const pageLocale = currentPage?.frontmatter.locale;
29
+ return typeof pageLocale === "string" ? pageLocale : siteLocale.locale();
30
+ };
31
+ const localizedTree = () => localizeSidebarTree(props.tree, props.pages || [], activeLocale());
23
32
  const renderCategoryIcon = (name) => (<Show when={renderIcon(name, "size-4 shrink-0")} fallback={<Folder class="size-4 shrink-0"/>}>
24
33
  {renderIcon(name, "size-4 shrink-0")}
25
34
  </Show>);
@@ -117,7 +126,7 @@ export const SidebarTree = (props) => {
117
126
  </SidebarGroupContent>
118
127
  </SidebarGroup>);
119
128
  return (<>
120
- <For each={props.tree.filter((item) => !item.items)}>{(item) => renderRootPage(item)}</For>
121
- <For each={props.tree.filter((item) => Boolean(item.items))}>{(group) => renderCategory(group)}</For>
129
+ <For each={localizedTree().filter((item) => !item.items)}>{(item) => renderRootPage(item)}</For>
130
+ <For each={localizedTree().filter((item) => Boolean(item.items))}>{(group) => renderCategory(group)}</For>
122
131
  </>);
123
132
  };
@@ -8,7 +8,10 @@ import { CommandGroup } from "@/components/ui/command";
8
8
  import { CommandItem } from "@/components/ui/command";
9
9
  import { FileText } from "lucide-solid";
10
10
  import { resolveSearchProvider, searchPages } from "../../../search/provider.js";
11
+ import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
11
12
  export const DocsSearchDialog = (props) => {
13
+ const siteLocale = useSiteLocale();
14
+ const showAlgoliaAttribution = () => typeof props.provider !== "string" && props.provider?.name === "algolia";
12
15
  const handleOpenChange = (open) => {
13
16
  props.onOpenChange(open);
14
17
  };
@@ -47,19 +50,27 @@ export const DocsSearchDialog = (props) => {
47
50
  });
48
51
  });
49
52
  return (<>
50
- <CommandInput id="docs-search-input" placeholder="Search documentation..."/>
53
+ <CommandInput id="docs-search-input" placeholder={siteLocale.t("search.placeholder")}/>
51
54
  <CommandList>
52
55
  <Show when={!searching() && query().length > 0 && filteredPages().length === 0}>
53
- <CommandEmpty>No matching documents found.</CommandEmpty>
56
+ <CommandEmpty>{siteLocale.t("search.empty")}</CommandEmpty>
54
57
  </Show>
55
58
  <Show when={!searching() && filteredPages().length > 0}>
56
- <CommandGroup heading="Pages">
59
+ <CommandGroup heading={siteLocale.t("search.pages")}>
57
60
  <For each={filteredPages()}>
58
61
  {(page) => (<CommandItem title={page.title} subtitle={page.url} description={page.description} icon={FileText} shouldFilter={false} onSelect={() => handleSelect(page.url)}/>)}
59
62
  </For>
60
63
  </CommandGroup>
61
64
  </Show>
62
65
  </CommandList>
66
+ <Show when={showAlgoliaAttribution()}>
67
+ <div class="flex items-center justify-end border-t border-border px-3 py-2">
68
+ <a href="https://www.algolia.com" target="_blank" rel="noreferrer" class="inline-flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground" aria-label={`${siteLocale.t("search.by")} Algolia`}>
69
+ <span>{siteLocale.t("search.by")}</span>
70
+ <img src="/algolia-logo.svg" alt="Algolia" class="h-4 w-auto object-contain"/>
71
+ </a>
72
+ </div>
73
+ </Show>
63
74
  </>);
64
75
  }}
65
76
  </CommandDialog>);
@@ -12,9 +12,11 @@ import { createFocusTrap } from "@/hooks/create-focus-trap";
12
12
  import { createLockScroll } from "@/hooks/create-lock-scroll";
13
13
  import { cn } from "@/lib/cn";
14
14
  import { SidebarTree } from "./navigation/sidebar-tree.jsx";
15
+ import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
15
16
  export const DocsSidebar = (props) => {
16
- const [local, rest] = splitProps(props, ["tree", "nav", "currentUrl", "title", "logo", "headerSubtitle", "footerText", "showHeader", "showFooter", "class"]);
17
+ const [local, rest] = splitProps(props, ["tree", "pages", "nav", "currentUrl", "title", "logo", "headerSubtitle", "footerText", "showHeader", "showFooter", "class"]);
17
18
  const brandText = () => local.logo?.text || local.title || "Folio";
19
+ const siteLocale = useSiteLocale();
18
20
  const sidebar = useSidebar();
19
21
  const [sidebarElement, setSidebarElement] = createSignal();
20
22
  createFocusTrap(sidebarElement, {
@@ -37,7 +39,7 @@ export const DocsSidebar = (props) => {
37
39
  });
38
40
  return (<>
39
41
  <Show when={sidebar.isMobile() && sidebar.openMobile()}>
40
- <button type="button" aria-label="Close documentation sidebar" class="fixed inset-0 z-40 cursor-default bg-black/50 md:hidden" onClick={() => sidebar.setOpenMobile(false)}/>
42
+ <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)}/>
41
43
  </Show>
42
44
  <Show when={!sidebar.isMobile() || sidebar.openMobile()}>
43
45
  <div class={cn("w-0 md:shrink-0", sidebar.open() ? "md:w-[var(--sidebar-width)]" : "md:w-[var(--sidebar-width-icon)]")}>
@@ -46,7 +48,7 @@ export const DocsSidebar = (props) => {
46
48
  <SidebarHeader class="h-14 box-border p-3 group-data-[collapsible=icon]:p-2">
47
49
  <a href={local.logo?.href || "/"} data-sidebar="menu-button" class={cn(sidebarMenuButtonVariants({ variant: "default", size: "default" }), "h-8 w-full justify-between group-data-[collapsible=icon]:h-10")}>
48
50
  <div class="flex items-center gap-2.5 overflow-hidden">
49
- <Show when={local.logo?.image} fallback={<Logo class="size-7"/>}>
51
+ <Show when={local.logo?.image} fallback={<Logo class="h-7 w-auto"/>}>
50
52
  {(image) => <img src={image()} alt={brandText()} class="size-7 shrink-0 rounded-md object-contain"/>}
51
53
  </Show>
52
54
  <div class="flex min-w-0 flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
@@ -60,7 +62,7 @@ export const DocsSidebar = (props) => {
60
62
 
61
63
  <SidebarContent class="h-full overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
62
64
  <Show when={local.nav?.length}>
63
- <nav aria-label="Primary navigation" class="border-b border-border/60 px-2 py-2 md:hidden">
65
+ <nav aria-label={siteLocale.t("navigation.primary")} class="border-b border-border/60 px-2 py-2 md:hidden">
64
66
  <For each={local.nav}>
65
67
  {(item) => (<a href={item.href} target={item.external ? "_blank" : undefined} rel={item.external ? "noreferrer" : undefined} onClick={() => sidebar.setOpenMobile(false)} class={cn(sidebarMenuButtonVariants({ variant: "default", size: "default" }), "w-full justify-start text-sm font-normal")}>
66
68
  {item.title}
@@ -68,7 +70,7 @@ export const DocsSidebar = (props) => {
68
70
  </For>
69
71
  </nav>
70
72
  </Show>
71
- <SidebarTree tree={local.tree} currentUrl={local.currentUrl}/>
73
+ <SidebarTree tree={local.tree} pages={local.pages} currentUrl={local.currentUrl}/>
72
74
  </SidebarContent>
73
75
 
74
76
  <Show when={local.showFooter !== false}>
@@ -7,6 +7,9 @@ export type BreadcrumbItemData = {
7
7
  };
8
8
  export interface DocsNavbarProps {
9
9
  config: DocsConfig;
10
+ currentPage?: PageData;
11
+ pages?: readonly PageData[];
12
+ onNavigate?: (url: string) => void;
10
13
  onOpenSearch?: () => void;
11
14
  showBrand?: boolean;
12
15
  showSidebarTrigger?: boolean;
@@ -15,6 +18,7 @@ export interface DocsNavbarProps {
15
18
  }
16
19
  export interface DocsSidebarProps {
17
20
  tree: SidebarItem[];
21
+ pages?: readonly PageData[];
18
22
  nav?: NavItem[];
19
23
  currentUrl?: string;
20
24
  title?: string;
@@ -59,6 +63,7 @@ export interface DocsLayoutProps {
59
63
  tree: SidebarItem[];
60
64
  pages?: PageData[];
61
65
  currentPage?: PageData;
66
+ onNavigate?: (url: string) => void;
62
67
  breadcrumbs?: BreadcrumbItemData[];
63
68
  toc?: TocItem[];
64
69
  prev?: {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { Component } from "solid-js";
2
+ import type { FolioPluginConfig } from "./plugin.js";
3
+ import type { DocsUiLocaleConfig } from "./plugins/i18n/site-locale.js";
2
4
  export type DocsIcon = Component<{
3
5
  class?: string;
4
6
  "aria-hidden"?: boolean | "true" | "false";
@@ -11,6 +13,8 @@ export interface Frontmatter {
11
13
  icon?: string;
12
14
  badge?: string;
13
15
  addedAt?: string;
16
+ updatedAt?: string;
17
+ noindex?: boolean;
14
18
  prev?: string | {
15
19
  title: string;
16
20
  href: string;
@@ -27,6 +31,14 @@ export interface TocItem {
27
31
  text: string;
28
32
  depth: number;
29
33
  }
34
+ export interface DocsPageAction {
35
+ /** Accessible text rendered inside the page action link. */
36
+ label: string;
37
+ /** Destination opened when the visitor activates the action. */
38
+ href: string;
39
+ /** Open external destinations in a new tab with safe link attributes. */
40
+ external?: boolean;
41
+ }
30
42
  export interface PageData {
31
43
  slug: string;
32
44
  url: string;
@@ -36,6 +48,7 @@ export interface PageData {
36
48
  toc: TocItem[];
37
49
  title: string;
38
50
  description?: string;
51
+ pageActions?: DocsPageAction[];
39
52
  }
40
53
  export interface SidebarItem {
41
54
  title: string;
@@ -67,6 +80,12 @@ export interface DocsNavigationConfig {
67
80
  footer?: boolean;
68
81
  headerSubtitle?: string;
69
82
  footerText?: string;
83
+ promo?: {
84
+ title: string;
85
+ description: string;
86
+ href: string;
87
+ cta?: string;
88
+ };
70
89
  };
71
90
  }
72
91
  export interface DocsHomeConfig {
@@ -96,6 +115,18 @@ export interface ShikiConfig {
96
115
  };
97
116
  langs?: string[];
98
117
  }
118
+ export interface DocsSeoConfig {
119
+ /** Social preview image path or URL. */
120
+ image?: string;
121
+ /** Accessible alternative text for the social preview image. */
122
+ imageAlt?: string;
123
+ /** Site name used by social metadata. Defaults to the configured title. */
124
+ siteName?: string;
125
+ /** Open Graph locale. Defaults to `en_US`. */
126
+ locale?: string;
127
+ /** Twitter/X card type. */
128
+ twitterCard?: "summary" | "summary_large_image";
129
+ }
99
130
  export interface DocsConfig {
100
131
  title?: string;
101
132
  description?: string;
@@ -123,10 +154,15 @@ export interface DocsConfig {
123
154
  sidebar?: SidebarItem[] | "auto";
124
155
  navigation?: DocsNavigationConfig;
125
156
  theme?: DocsThemeConfig;
157
+ seo?: DocsSeoConfig;
126
158
  shiki?: ShikiConfig;
127
159
  search?: {
128
160
  enabled?: boolean;
129
161
  /** A provider name or a configured adapter instance. */
130
162
  provider?: string | import("./search/provider.js").SearchAdapter;
131
163
  };
164
+ /** Resolved JSON-backed translations for the documentation interface. */
165
+ uiLocale?: DocsUiLocaleConfig;
166
+ /** Build-time extensions created by Folio plugin factories. */
167
+ plugins?: FolioPluginConfig;
132
168
  }
@@ -0,0 +1 @@
1
+ export declare function formatTitleFromFilename(filename: string): string;
@@ -0,0 +1,11 @@
1
+ export function formatTitleFromFilename(filename) {
2
+ const basename = filename.replace(/\\/g, "/").split("/").pop() || filename;
3
+ const extensionIndex = basename.lastIndexOf(".");
4
+ const base = extensionIndex > 0 ? basename.slice(0, extensionIndex) : basename;
5
+ if (base === "index")
6
+ return "Overview";
7
+ return base
8
+ .split(/[-_]/)
9
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
10
+ .join(" ");
11
+ }