@umami/shiso 1.9.0 → 1.10.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.
@@ -14,6 +14,40 @@ import shiso from "virtual:shiso-config";
14
14
  import rawConfig from "virtual:shiso-docs-config";
15
15
  import { LAST_MODIFIED } from "@/generated/last-modified";
16
16
 
17
+ //#region ../../node_modules/.pnpm/lucide-react@1.28.0_react@19.2.8/node_modules/lucide-react/dist/esm/icons/arrow-left.mjs
18
+ /**
19
+ * @license lucide-react v1.28.0 - ISC
20
+ *
21
+ * This source code is licensed under the ISC license.
22
+ * See the LICENSE file in the root directory of this source tree.
23
+ */
24
+ const __iconNode$10 = [["path", {
25
+ d: "m12 19-7-7 7-7",
26
+ key: "1l729n"
27
+ }], ["path", {
28
+ d: "M19 12H5",
29
+ key: "x3x0zl"
30
+ }]];
31
+ const ArrowLeft = createLucideIcon("arrow-left", __iconNode$10);
32
+
33
+ //#endregion
34
+ //#region ../../node_modules/.pnpm/lucide-react@1.28.0_react@19.2.8/node_modules/lucide-react/dist/esm/icons/arrow-right.mjs
35
+ /**
36
+ * @license lucide-react v1.28.0 - ISC
37
+ *
38
+ * This source code is licensed under the ISC license.
39
+ * See the LICENSE file in the root directory of this source tree.
40
+ */
41
+ const __iconNode$9 = [["path", {
42
+ d: "M5 12h14",
43
+ key: "1ays0h"
44
+ }], ["path", {
45
+ d: "m12 5 7 7-7 7",
46
+ key: "xquz4c"
47
+ }]];
48
+ const ArrowRight = createLucideIcon("arrow-right", __iconNode$9);
49
+
50
+ //#endregion
17
51
  //#region ../../node_modules/.pnpm/lucide-react@1.28.0_react@19.2.8/node_modules/lucide-react/dist/esm/icons/copy.mjs
18
52
  /**
19
53
  * @license lucide-react v1.28.0 - ISC
@@ -4026,11 +4060,24 @@ const DEFAULT_SEARCH_PROMPT = "Search...";
4026
4060
  const DEFAULT_SEARCH_PROVIDER = "local";
4027
4061
  const DEFAULT_SEARCH_SHORTCUT = "k";
4028
4062
  const DEFAULT_SEARCH_SHORTCUT_LABEL = "Ctrl K";
4063
+ const DEFAULT_SEARCH_POSITION = "header";
4064
+ /** Positions the built-in theme knows how to render. */
4065
+ const SEARCH_POSITIONS = ["header", "sidebar"];
4066
+ /**
4067
+ * Themes must always support "header", so anything unrecognized (or not
4068
+ * implemented by the active theme) lands there instead of vanishing.
4069
+ */
4070
+ function resolveSearchPosition(position, supported = SEARCH_POSITIONS) {
4071
+ if (typeof position === "string" && supported.includes(position)) return position;
4072
+ if (position !== void 0 && position !== "header") console.warn(`[shiso] Unsupported search.position "${String(position)}" — using "${DEFAULT_SEARCH_POSITION}".`);
4073
+ return DEFAULT_SEARCH_POSITION;
4074
+ }
4029
4075
  /** Normalizes docs.json search settings for both the UI and provider loader. */
4030
4076
  function resolveSearchConfig(config) {
4031
4077
  if (config === false) return {
4032
4078
  enabled: false,
4033
4079
  prompt: DEFAULT_SEARCH_PROMPT,
4080
+ position: DEFAULT_SEARCH_POSITION,
4034
4081
  provider: DEFAULT_SEARCH_PROVIDER,
4035
4082
  options: {},
4036
4083
  shortcut: false,
@@ -4039,6 +4086,7 @@ function resolveSearchConfig(config) {
4039
4086
  return {
4040
4087
  enabled: true,
4041
4088
  prompt: config?.prompt?.trim() || "Search...",
4089
+ position: resolveSearchPosition(config?.position),
4042
4090
  provider: config?.provider?.trim().toLowerCase() || "local",
4043
4091
  options: config?.options || {},
4044
4092
  shortcut: config?.shortcut === false ? false : config?.shortcut?.trim().toLowerCase() || "k",
@@ -4060,6 +4108,8 @@ const SHISO_THEME_LABELS = {
4060
4108
  noResults: "No results",
4061
4109
  lastUpdated: "Last updated on",
4062
4110
  relatedTopics: "Related topics",
4111
+ previousPage: "Previous",
4112
+ nextPage: "Next",
4063
4113
  notFound: "Page not found",
4064
4114
  dismissBanner: "Dismiss banner",
4065
4115
  toggleTheme: "Toggle theme",
@@ -7205,7 +7255,7 @@ function renderWithQueryHighlight(text, query) {
7205
7255
  * Provider-neutral search dialog. The selected provider and its index or
7206
7256
  * client are loaded on demand, so search stays out of the initial bundle.
7207
7257
  */
7208
- function Search({ config, labels }) {
7258
+ function Search({ config, labels, className }) {
7209
7259
  const navigate = useNavigate();
7210
7260
  const { pathname } = useLocation();
7211
7261
  const [open, setOpen] = useState(false);
@@ -7294,12 +7344,12 @@ function Search({ config, labels }) {
7294
7344
  children: [/* @__PURE__ */ jsxs(DialogTrigger, {
7295
7345
  render: /* @__PURE__ */ jsx(Button, {
7296
7346
  variant: "outline",
7297
- className: "h-auto gap-2 rounded-md bg-card px-2.5 py-1.5 text-muted-foreground hover:border-input hover:bg-card hover:text-foreground"
7347
+ className: cn("h-auto gap-2 rounded-md bg-card px-2.5 py-1.5 text-muted-foreground hover:border-input hover:bg-card hover:text-foreground", className)
7298
7348
  }),
7299
7349
  children: [
7300
7350
  /* @__PURE__ */ jsx(Search$1, { className: "size-3.5" }),
7301
7351
  /* @__PURE__ */ jsx("span", {
7302
- className: "min-w-24 text-left",
7352
+ className: "min-w-24 grow text-left",
7303
7353
  children: config.prompt
7304
7354
  }),
7305
7355
  config.shortcut ? /* @__PURE__ */ jsx("kbd", {
@@ -7348,6 +7398,21 @@ function Search({ config, labels }) {
7348
7398
  })]
7349
7399
  });
7350
7400
  }
7401
+ /**
7402
+ * Renders the search control only when `search.position` targets this slot.
7403
+ * Layout components drop one of these into each position they support; the
7404
+ * per-page `search: false` frontmatter flag is honored here as well.
7405
+ */
7406
+ function SearchSlot({ site, position, className }) {
7407
+ const { pathname } = useLocation();
7408
+ if (!site.search.enabled || site.search.position !== position) return null;
7409
+ if (getPageFrontmatter(pathname)?.search === false) return null;
7410
+ return /* @__PURE__ */ jsx(Search, {
7411
+ config: site.search,
7412
+ labels: site.labels,
7413
+ className
7414
+ });
7415
+ }
7351
7416
 
7352
7417
  //#endregion
7353
7418
  //#region src/components/ThemeToggle.tsx
@@ -7527,10 +7592,9 @@ function NavbarLinkItem({ link, primary = false }) {
7527
7592
  });
7528
7593
  }
7529
7594
  function Header({ site }) {
7530
- const { logo, navbar, name, appearance, labels, search } = site;
7595
+ const { logo, navbar, name, appearance, labels } = site;
7531
7596
  const { pathname } = useLocation();
7532
7597
  const docs = getScopeByPathname(pathname).docs;
7533
- const showSearch = getPageFrontmatter(pathname)?.search !== false;
7534
7598
  const brandHref = logo?.href || (hasRootStandalonePage ? "/" : docsHomeUrl);
7535
7599
  const hasBrand = !!name || !!logo?.light || !!logo?.dark;
7536
7600
  const brandClassName = "inline-flex items-center gap-2 text-xl font-bold text-foreground tracking-[-0.03em]";
@@ -7579,10 +7643,15 @@ function Header({ site }) {
7579
7643
  /* @__PURE__ */ jsxs("div", {
7580
7644
  className: "flex min-w-0 items-center gap-2 justify-self-end",
7581
7645
  children: [
7582
- showSearch ? /* @__PURE__ */ jsx(Search, {
7583
- config: search,
7584
- labels
7585
- }) : null,
7646
+ /* @__PURE__ */ jsx(SearchSlot, {
7647
+ site,
7648
+ position: "header"
7649
+ }),
7650
+ /* @__PURE__ */ jsx(SearchSlot, {
7651
+ site,
7652
+ position: "sidebar",
7653
+ className: "lg:hidden"
7654
+ }),
7586
7655
  navbar?.links.map((link) => /* @__PURE__ */ jsx(NavbarLinkItem, { link }, link.href)),
7587
7656
  !appearance.strict && /* @__PURE__ */ jsx(ThemeToggle, { label: labels.toggleTheme }),
7588
7657
  navbar?.primary ? /* @__PURE__ */ jsx(NavbarLinkItem, {
@@ -8001,30 +8070,44 @@ function DocContent({ page, doc, site }) {
8001
8070
  })]
8002
8071
  }),
8003
8072
  /* @__PURE__ */ jsxs("div", {
8004
- className: "mt-8 flex items-center justify-between",
8073
+ className: "mt-8 flex items-end justify-between",
8005
8074
  "data-pagefind-ignore": true,
8006
8075
  children: [/* @__PURE__ */ jsx(NavigationButton, {
8007
8076
  ...prev,
8077
+ eyebrow: site.labels.previousPage,
8008
8078
  isPrev: true
8009
- }), /* @__PURE__ */ jsx(NavigationButton, { ...next })]
8079
+ }), /* @__PURE__ */ jsx(NavigationButton, {
8080
+ ...next,
8081
+ eyebrow: site.labels.nextPage
8082
+ })]
8010
8083
  })
8011
8084
  ]
8012
8085
  });
8013
8086
  }
8014
- const NavigationButton = ({ label, url, isPrev }) => {
8087
+ const NavigationButton = ({ label, url, eyebrow, isPrev }) => {
8015
8088
  if (!url || !label) return /* @__PURE__ */ jsx("div", {});
8016
8089
  return /* @__PURE__ */ jsxs(Link, {
8017
8090
  to: url,
8018
- className: "group my-3 inline-flex items-center gap-3 text-base font-bold text-foreground",
8091
+ className: cn("group my-3 inline-flex items-end gap-3 text-base text-foreground", { "text-right": !isPrev }),
8092
+ rel: isPrev ? "prev" : "next",
8019
8093
  children: [
8020
- isPrev && /* @__PURE__ */ jsx(ChevronRight, {
8094
+ isPrev && /* @__PURE__ */ jsx(ArrowLeft, {
8021
8095
  size: 14,
8022
- className: "rotate-180 text-muted-foreground transition-colors group-hover:text-foreground"
8096
+ className: "mb-[0.3rem] text-muted-foreground transition-colors group-hover:text-foreground"
8023
8097
  }),
8024
- label,
8025
- !isPrev && /* @__PURE__ */ jsx(ChevronRight, {
8098
+ /* @__PURE__ */ jsxs("span", {
8099
+ className: "flex flex-col",
8100
+ children: [/* @__PURE__ */ jsx("span", {
8101
+ className: "text-xs font-bold text-muted-foreground",
8102
+ children: eyebrow
8103
+ }), /* @__PURE__ */ jsx("span", {
8104
+ className: "font-medium transition-colors group-hover:text-primary",
8105
+ children: label
8106
+ })]
8107
+ }),
8108
+ !isPrev && /* @__PURE__ */ jsx(ArrowRight, {
8026
8109
  size: 14,
8027
- className: "text-muted-foreground transition-colors group-hover:text-foreground"
8110
+ className: "mb-[0.3rem] text-muted-foreground transition-colors group-hover:text-foreground"
8028
8111
  })
8029
8112
  ]
8030
8113
  });
@@ -8307,7 +8390,7 @@ function SideNav({ tabs, navigation, anchors, activeTabId, isSticky, drilldown,
8307
8390
  const { pathname } = useLocation();
8308
8391
  const nodes = navigation[activeTabId] || navigation[tabs[0]?.id] || [];
8309
8392
  return /* @__PURE__ */ jsx(ScrollArea, {
8310
- className: cn("w-full max-w-full", { "h-full": isSticky }),
8393
+ className: cn("w-full max-w-full", { "min-h-0 grow": isSticky }),
8311
8394
  children: /* @__PURE__ */ jsxs("nav", {
8312
8395
  className: "flex w-full flex-col gap-6 pr-4 text-sm",
8313
8396
  "aria-label": navigationLabel,
@@ -8462,9 +8545,13 @@ function Docs({ page, doc, site }) {
8462
8545
  })]
8463
8546
  }), /* @__PURE__ */ jsxs("div", {
8464
8547
  className: "flex items-start gap-12 lg:min-h-[calc(100dvh-var(--header-height))] lg:pt-6",
8465
- children: [/* @__PURE__ */ jsx("div", {
8466
- className: "hidden min-w-0 max-w-60 basis-60 self-start lg:sticky lg:top-[calc(var(--header-height)+1.5rem)] lg:block lg:h-[calc(100dvh-var(--header-height)-3rem)] lg:shrink-0",
8467
- children: /* @__PURE__ */ jsx(SideNav, {
8548
+ children: [/* @__PURE__ */ jsxs("div", {
8549
+ className: "hidden min-w-0 max-w-60 basis-60 flex-col gap-4 self-start lg:sticky lg:top-[calc(var(--header-height)+1.5rem)] lg:flex lg:h-[calc(100dvh-var(--header-height)-3rem)] lg:shrink-0",
8550
+ children: [/* @__PURE__ */ jsx(SearchSlot, {
8551
+ site,
8552
+ position: "sidebar",
8553
+ className: "w-full"
8554
+ }), /* @__PURE__ */ jsx(SideNav, {
8468
8555
  tabs,
8469
8556
  navigation,
8470
8557
  anchors: scopeDocs.anchors,
@@ -8474,7 +8561,7 @@ function Docs({ page, doc, site }) {
8474
8561
  navigationLabel: site.labels.documentationNavigation,
8475
8562
  expandLabel: site.labels.expand,
8476
8563
  collapseLabel: site.labels.collapse
8477
- })
8564
+ })]
8478
8565
  }), /* @__PURE__ */ jsxs("div", {
8479
8566
  className: "flex min-w-0 grow self-stretch flex-col",
8480
8567
  children: [/* @__PURE__ */ jsxs("div", {
package/docs.schema.json CHANGED
@@ -279,6 +279,14 @@
279
279
  "allOf": [{ "$ref": "#/definitions/stringValue" }],
280
280
  "description": "Placeholder text for the search input."
281
281
  },
282
+ "position": {
283
+ "anyOf": [
284
+ { "type": "string", "enum": ["header", "sidebar"] },
285
+ { "$ref": "#/definitions/configRefValue" }
286
+ ],
287
+ "default": "header",
288
+ "description": "Where the search control renders: \"header\" (right side of the header) or \"sidebar\" (top of the navigation column; stays in the header on small screens). Themes that do not support a position fall back to \"header\"."
289
+ },
282
290
  "provider": {
283
291
  "allOf": [{ "$ref": "#/definitions/nonEmptyStringValue" }],
284
292
  "description": "Search provider id: \"local\" (default), \"pagefind\", or a provider registered at runtime."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umami/shiso",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Open-source documentation framework for Markdown and MDX sites.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,12 +1,13 @@
1
1
  import { Link } from 'react-router';
2
2
  import { ContextualMenu } from '@/components/ContextualMenu';
3
- import { ChevronRight, FileText } from '@/components/icons';
3
+ import { ArrowLeft, ArrowRight, FileText } from '@/components/icons';
4
4
  import { getLastModified } from '@/lib/content';
5
5
  import { getScopeForPage } from '@/lib/docs-config';
6
6
  import { resolveLocale } from '@/lib/locale';
7
7
  import { docsSite, getPageByPathname } from '@/lib/site-config';
8
8
  import { resolveContextualOptions } from '@/lib/site-model';
9
9
  import type { DocModule, NormalizedDocsPage, RelatedEntry, SiteModel } from '@/lib/types';
10
+ import { cn } from '@/lib/utils';
10
11
 
11
12
  interface RelatedLink {
12
13
  href: string;
@@ -148,9 +149,9 @@ export function DocContent({ page, doc, site }: DocContentProps) {
148
149
  </ul>
149
150
  </nav>
150
151
  )}
151
- <div className="mt-8 flex items-center justify-between" data-pagefind-ignore>
152
- <NavigationButton {...prev} isPrev />
153
- <NavigationButton {...next} />
152
+ <div className="mt-8 flex items-end justify-between" data-pagefind-ignore>
153
+ <NavigationButton {...prev} eyebrow={site.labels.previousPage} isPrev />
154
+ <NavigationButton {...next} eyebrow={site.labels.nextPage} />
154
155
  </div>
155
156
  </article>
156
157
  );
@@ -159,10 +160,13 @@ export function DocContent({ page, doc, site }: DocContentProps) {
159
160
  const NavigationButton = ({
160
161
  label,
161
162
  url,
163
+ eyebrow,
162
164
  isPrev,
163
165
  }: {
164
166
  label?: string;
165
167
  url?: string;
168
+ /** Direction caption ("Previous" / "Next") shown above the page title. */
169
+ eyebrow: string;
166
170
  isPrev?: boolean;
167
171
  }) => {
168
172
  if (!url || !label) {
@@ -172,19 +176,25 @@ const NavigationButton = ({
172
176
  return (
173
177
  <Link
174
178
  to={url}
175
- className="group my-3 inline-flex items-center gap-3 text-base font-bold text-foreground"
179
+ className={cn('group my-3 inline-flex items-end gap-3 text-base text-foreground', {
180
+ 'text-right': !isPrev,
181
+ })}
182
+ rel={isPrev ? 'prev' : 'next'}
176
183
  >
177
184
  {isPrev && (
178
- <ChevronRight
185
+ <ArrowLeft
179
186
  size={14}
180
- className="rotate-180 text-muted-foreground transition-colors group-hover:text-foreground"
187
+ className="mb-[0.3rem] text-muted-foreground transition-colors group-hover:text-foreground"
181
188
  />
182
189
  )}
183
- {label}
190
+ <span className="flex flex-col">
191
+ <span className="text-xs font-bold text-muted-foreground">{eyebrow}</span>
192
+ <span className="font-medium transition-colors group-hover:text-primary">{label}</span>
193
+ </span>
184
194
  {!isPrev && (
185
- <ChevronRight
195
+ <ArrowRight
186
196
  size={14}
187
- className="text-muted-foreground transition-colors group-hover:text-foreground"
197
+ className="mb-[0.3rem] text-muted-foreground transition-colors group-hover:text-foreground"
188
198
  />
189
199
  )}
190
200
  </Link>
@@ -5,6 +5,7 @@ import { Footer } from '@/components/Footer';
5
5
  import { Menu } from '@/components/icons';
6
6
  import { LanguageSwitcher } from '@/components/LanguageSwitcher';
7
7
  import { PageLinks } from '@/components/PageLinks';
8
+ import { SearchSlot } from '@/components/Search';
8
9
  import { SideNav } from '@/components/SideNav';
9
10
  import { Button } from '@/components/ui/button';
10
11
  import { Sheet, SheetContent, SheetTitle, SheetTrigger } from '@/components/ui/sheet';
@@ -104,7 +105,8 @@ export function Docs({ page, doc, site }: DocsProps) {
104
105
  </SheetContent>
105
106
  </Sheet>
106
107
  <div className="flex items-start gap-12 lg:min-h-[calc(100dvh-var(--header-height))] lg:pt-6">
107
- <div className="hidden min-w-0 max-w-60 basis-60 self-start lg:sticky lg:top-[calc(var(--header-height)+1.5rem)] lg:block lg:h-[calc(100dvh-var(--header-height)-3rem)] lg:shrink-0">
108
+ <div className="hidden min-w-0 max-w-60 basis-60 flex-col gap-4 self-start lg:sticky lg:top-[calc(var(--header-height)+1.5rem)] lg:flex lg:h-[calc(100dvh-var(--header-height)-3rem)] lg:shrink-0">
109
+ <SearchSlot site={site} position="sidebar" className="w-full" />
108
110
  <SideNav
109
111
  tabs={tabs}
110
112
  navigation={navigation}
@@ -1,17 +1,12 @@
1
1
  import { Link, useLocation } from 'react-router';
2
2
  import { ConfiguredIcon } from '@/components/ConfiguredIcon';
3
3
  import { LanguageSwitcher } from '@/components/LanguageSwitcher';
4
- import { Search } from '@/components/Search';
4
+ import { SearchSlot } from '@/components/Search';
5
5
  import { ThemeToggle } from '@/components/ThemeToggle';
6
6
  import { TopNav } from '@/components/TopNav';
7
7
  import { VersionSwitcher } from '@/components/VersionSwitcher';
8
8
  import { isExternalHref } from '@/lib/paths';
9
- import {
10
- docsHomeUrl,
11
- getPageFrontmatter,
12
- getScopeByPathname,
13
- hasRootStandalonePage,
14
- } from '@/lib/site-config';
9
+ import { docsHomeUrl, getScopeByPathname, hasRootStandalonePage } from '@/lib/site-config';
15
10
  import type { NormalizedLink, SiteModel } from '@/lib/types';
16
11
 
17
12
  /**
@@ -63,11 +58,10 @@ function NavbarLinkItem({ link, primary = false }: { link: NormalizedLink; prima
63
58
  }
64
59
 
65
60
  export function Header({ site }: { site: SiteModel }) {
66
- const { logo, navbar, name, appearance, labels, search } = site;
61
+ const { logo, navbar, name, appearance, labels } = site;
67
62
  const { pathname } = useLocation();
68
63
  // The header renders the navigation of whichever scope owns the current page.
69
64
  const docs = getScopeByPathname(pathname).docs;
70
- const showSearch = getPageFrontmatter(pathname)?.search !== false;
71
65
  // The brand links to the standalone home page when one owns "/".
72
66
  const brandHref = logo?.href || (hasRootStandalonePage ? '/' : docsHomeUrl);
73
67
  const hasBrand = !!name || !!logo?.light || !!logo?.dark;
@@ -120,7 +114,10 @@ export function Header({ site }: { site: SiteModel }) {
120
114
  {docs.showTabs ? <TopNav docs={docs} label={labels.sections} /> : null}
121
115
  </div>
122
116
  <div className="flex min-w-0 items-center gap-2 justify-self-end">
123
- {showSearch ? <Search config={search} labels={labels} /> : null}
117
+ <SearchSlot site={site} position="header" />
118
+ {/* The sidebar collapses into a sheet on small screens, so its
119
+ search control moves up here until the column is visible. */}
120
+ <SearchSlot site={site} position="sidebar" className="lg:hidden" />
124
121
  {navbar?.links.map(link => (
125
122
  <NavbarLinkItem key={link.href} link={link} />
126
123
  ))}
@@ -14,8 +14,9 @@ import { Dialog, DialogContent, DialogTitle, DialogTrigger } from '@/components/
14
14
  import { highlightTerms, type SearchResult } from '@/lib/search';
15
15
  import type { ResolvedSearchConfig } from '@/lib/search/config';
16
16
  import { resolveSearchProvider, type SearchProvider } from '@/lib/search/provider';
17
- import { getScopeByPathname } from '@/lib/site-config';
18
- import type { ThemeLabels } from '@/lib/types';
17
+ import { getPageFrontmatter, getScopeByPathname } from '@/lib/site-config';
18
+ import type { SearchPosition, SiteModel, ThemeLabels } from '@/lib/types';
19
+ import { cn } from '@/lib/utils';
19
20
 
20
21
  /** Enough results to make the list scroll; the dialog caps its own height. */
21
22
  const RESULT_LIMIT = 30;
@@ -54,7 +55,16 @@ function renderWithQueryHighlight(text: string, query: string) {
54
55
  * Provider-neutral search dialog. The selected provider and its index or
55
56
  * client are loaded on demand, so search stays out of the initial bundle.
56
57
  */
57
- export function Search({ config, labels }: { config: ResolvedSearchConfig; labels: ThemeLabels }) {
58
+ export function Search({
59
+ config,
60
+ labels,
61
+ className,
62
+ }: {
63
+ config: ResolvedSearchConfig;
64
+ labels: ThemeLabels;
65
+ /** Extra classes for the trigger button (e.g. to stretch it in a column). */
66
+ className?: string;
67
+ }) {
58
68
  const navigate = useNavigate();
59
69
  const { pathname } = useLocation();
60
70
  const [open, setOpen] = useState(false);
@@ -179,12 +189,15 @@ export function Search({ config, labels }: { config: ResolvedSearchConfig; label
179
189
  render={
180
190
  <Button
181
191
  variant="outline"
182
- className="h-auto gap-2 rounded-md bg-card px-2.5 py-1.5 text-muted-foreground hover:border-input hover:bg-card hover:text-foreground"
192
+ className={cn(
193
+ 'h-auto gap-2 rounded-md bg-card px-2.5 py-1.5 text-muted-foreground hover:border-input hover:bg-card hover:text-foreground',
194
+ className,
195
+ )}
183
196
  />
184
197
  }
185
198
  >
186
199
  <SearchIcon className="size-3.5" />
187
- <span className="min-w-24 text-left">{config.prompt}</span>
200
+ <span className="min-w-24 grow text-left">{config.prompt}</span>
188
201
  {config.shortcut ? (
189
202
  <kbd className="rounded-sm border border-border bg-muted px-[0.3rem] py-[0.05rem] text-[0.7rem] font-sans">
190
203
  {config.shortcutLabel}
@@ -253,3 +266,30 @@ export function Search({ config, labels }: { config: ResolvedSearchConfig; label
253
266
  </Dialog>
254
267
  );
255
268
  }
269
+
270
+ /**
271
+ * Renders the search control only when `search.position` targets this slot.
272
+ * Layout components drop one of these into each position they support; the
273
+ * per-page `search: false` frontmatter flag is honored here as well.
274
+ */
275
+ export function SearchSlot({
276
+ site,
277
+ position,
278
+ className,
279
+ }: {
280
+ site: SiteModel;
281
+ position: SearchPosition;
282
+ className?: string;
283
+ }) {
284
+ const { pathname } = useLocation();
285
+
286
+ if (!site.search.enabled || site.search.position !== position) {
287
+ return null;
288
+ }
289
+
290
+ if (getPageFrontmatter(pathname)?.search === false) {
291
+ return null;
292
+ }
293
+
294
+ return <Search config={site.search} labels={site.labels} className={className} />;
295
+ }
@@ -1,4 +1,3 @@
1
- import { cn } from '@/lib/utils';
2
1
  import { type ReactNode, useEffect, useState } from 'react';
3
2
  import { Link, useLocation, useNavigate } from 'react-router';
4
3
  import { resolveIcon } from '@/components/docs/utils';
@@ -9,9 +8,9 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/component
9
8
  import { ScrollArea } from '@/components/ui/scroll-area';
10
9
  import { flattenNav, isNodeHidden } from '@/lib/docs-config';
11
10
  import type { DocsTab, NavGroupNode, NavNode } from '@/lib/types';
11
+ import { cn } from '@/lib/utils';
12
12
 
13
- const sectionLabelClass =
14
- 'flex min-w-0 items-center gap-[0.4rem] pb-2 pr-1 font-bold text-inherit';
13
+ const sectionLabelClass = 'flex min-w-0 items-center gap-[0.4rem] pb-2 pr-1 font-bold text-inherit';
15
14
  const groupLabelClass =
16
15
  'flex min-w-0 items-center gap-[0.4rem] py-2 pl-3 pr-1 font-medium text-inherit';
17
16
  const selectedClass =
@@ -319,7 +318,7 @@ export function SideNav({
319
318
  const nodes = navigation[activeTabId] || navigation[tabs[0]?.id] || [];
320
319
 
321
320
  return (
322
- <ScrollArea className={cn('w-full max-w-full', { 'h-full': isSticky })}>
321
+ <ScrollArea className={cn('w-full max-w-full', { 'min-h-0 grow': isSticky })}>
323
322
  <nav className="flex w-full flex-col gap-6 pr-4 text-sm" aria-label={navigationLabel}>
324
323
  {anchors.length ? (
325
324
  <NavNodes
@@ -1,4 +1,6 @@
1
1
  export {
2
+ ArrowLeft,
3
+ ArrowRight,
2
4
  Check,
3
5
  Check as CheckIcon,
4
6
  ChevronRight,
@@ -1,13 +1,39 @@
1
- import type { SearchConfig } from '@/lib/types';
1
+ import type { SearchConfig, SearchPosition } from '@/lib/types';
2
2
 
3
3
  export const DEFAULT_SEARCH_PROMPT = 'Search...';
4
4
  export const DEFAULT_SEARCH_PROVIDER = 'local';
5
5
  export const DEFAULT_SEARCH_SHORTCUT = 'k';
6
6
  export const DEFAULT_SEARCH_SHORTCUT_LABEL = 'Ctrl K';
7
+ export const DEFAULT_SEARCH_POSITION: SearchPosition = 'header';
8
+
9
+ /** Positions the built-in theme knows how to render. */
10
+ export const SEARCH_POSITIONS: readonly SearchPosition[] = ['header', 'sidebar'];
11
+
12
+ /**
13
+ * Themes must always support "header", so anything unrecognized (or not
14
+ * implemented by the active theme) lands there instead of vanishing.
15
+ */
16
+ export function resolveSearchPosition(
17
+ position: unknown,
18
+ supported: readonly SearchPosition[] = SEARCH_POSITIONS,
19
+ ): SearchPosition {
20
+ if (typeof position === 'string' && (supported as readonly string[]).includes(position)) {
21
+ return position as SearchPosition;
22
+ }
23
+
24
+ if (position !== undefined && position !== DEFAULT_SEARCH_POSITION) {
25
+ console.warn(
26
+ `[shiso] Unsupported search.position "${String(position)}" — using "${DEFAULT_SEARCH_POSITION}".`,
27
+ );
28
+ }
29
+
30
+ return DEFAULT_SEARCH_POSITION;
31
+ }
7
32
 
8
33
  export interface ResolvedSearchConfig {
9
34
  enabled: boolean;
10
35
  prompt: string;
36
+ position: SearchPosition;
11
37
  provider: string;
12
38
  options: Record<string, unknown>;
13
39
  shortcut: string | false;
@@ -22,6 +48,7 @@ export function resolveSearchConfig(
22
48
  return {
23
49
  enabled: false,
24
50
  prompt: DEFAULT_SEARCH_PROMPT,
51
+ position: DEFAULT_SEARCH_POSITION,
25
52
  provider: DEFAULT_SEARCH_PROVIDER,
26
53
  options: {},
27
54
  shortcut: false,
@@ -32,6 +59,7 @@ export function resolveSearchConfig(
32
59
  return {
33
60
  enabled: true,
34
61
  prompt: config?.prompt?.trim() || DEFAULT_SEARCH_PROMPT,
62
+ position: resolveSearchPosition(config?.position),
35
63
  provider: config?.provider?.trim().toLowerCase() || DEFAULT_SEARCH_PROVIDER,
36
64
  options: config?.options || {},
37
65
  shortcut:
@@ -29,6 +29,8 @@ const SHISO_THEME_LABELS: ThemeLabels = {
29
29
  noResults: 'No results',
30
30
  lastUpdated: 'Last updated on',
31
31
  relatedTopics: 'Related topics',
32
+ previousPage: 'Previous',
33
+ nextPage: 'Next',
32
34
  notFound: 'Page not found',
33
35
  dismissBanner: 'Dismiss banner',
34
36
  toggleTheme: 'Toggle theme',
package/src/lib/types.ts CHANGED
@@ -255,9 +255,20 @@ export interface FontsConfig extends FontSpec {
255
255
  body?: FontSpec;
256
256
  }
257
257
 
258
+ /**
259
+ * Named slots a theme can place the search control in. Every theme must
260
+ * support "header"; unsupported positions fall back to it.
261
+ */
262
+ export type SearchPosition = 'header' | 'sidebar';
263
+
258
264
  export interface SearchConfig {
259
265
  /** Placeholder text for the search input. */
260
266
  prompt?: string;
267
+ /**
268
+ * Where the search control renders: "header" (default, right side of the
269
+ * header) or "sidebar" (top of the navigation column).
270
+ */
271
+ position?: SearchPosition;
261
272
  /** Provider id: "local" (default), "pagefind", or a runtime-registered id. */
262
273
  provider?: string;
263
274
  /** Provider-specific configuration. */
@@ -487,6 +498,8 @@ export interface ThemeLabels {
487
498
  noResults: string;
488
499
  lastUpdated: string;
489
500
  relatedTopics: string;
501
+ previousPage: string;
502
+ nextPage: string;
490
503
  notFound: string;
491
504
  dismissBanner: string;
492
505
  toggleTheme: string;
@@ -555,7 +568,7 @@ export interface DocFrontmatter {
555
568
  title?: string;
556
569
  description?: string;
557
570
  noindex?: boolean;
558
- /** Hide the header search control and disable its shortcut on this page. */
571
+ /** Hide the search control and disable its shortcut on this page. */
559
572
  search?: false;
560
573
  /** Overrides the site-wide `metadata.timestamp` setting for this page. */
561
574
  timestamp?: boolean;