@riebeckite/plugin-navigation 0.0.24 → 0.0.26

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.
@@ -1,9 +1,10 @@
1
1
  import type { NavigationItem } from "../src/types.js";
2
2
  export type SiteNavProps = {
3
+ readonly placement?: "primary" | "secondary";
3
4
  /** Navigation tree to render, in order. */
4
- readonly items: readonly NavigationItem[];
5
+ readonly items?: readonly NavigationItem[];
5
6
  /** Current request path, used to mark the active item. */
6
- readonly path: string;
7
+ readonly path?: string;
7
8
  /**
8
9
  * Current content language. When set, a matching `/language` prefix is
9
10
  * stripped from `path` before the active item is resolved.
@@ -16,6 +17,7 @@ export type SiteNavProps = {
16
17
  /** Extra classes appended to the `<nav>` landmark. */
17
18
  readonly class?: string;
18
19
  readonly className?: string;
20
+ readonly omitHome?: boolean;
19
21
  };
20
22
  /**
21
23
  * Renders a resolved navigation tree as a `<nav>` landmark with nested lists.
package/dist/index.js CHANGED
@@ -159,8 +159,21 @@ function isRecord(value) {
159
159
  }
160
160
 
161
161
  // components/site-nav.tsx
162
+ import { useSiteContext } from "@riebeckite/ui";
162
163
  import { jsx, jsxs } from "hono/jsx/jsx-runtime";
163
164
  function SiteNav(props) {
165
+ const site = useSiteContext();
166
+ const navigation2 = site ? resolveSiteNavigation(
167
+ site.config,
168
+ site.manifest,
169
+ props.language ?? site.language
170
+ ) : null;
171
+ const placement = props.placement ?? "primary";
172
+ const items = (props.items ?? navigation2?.[placement] ?? []).filter(
173
+ (item) => !props.omitHome || item.href !== "/"
174
+ );
175
+ const path = props.path ?? site?.path ?? "/";
176
+ if (items.length === 0 && props.items === void 0) return null;
164
177
  return /* @__PURE__ */ jsx(
165
178
  "nav",
166
179
  {
@@ -169,9 +182,9 @@ function SiteNav(props) {
169
182
  children: /* @__PURE__ */ jsx(
170
183
  NavigationItems,
171
184
  {
172
- items: props.items,
173
- path: props.path,
174
- language: props.language,
185
+ items,
186
+ path,
187
+ language: props.language ?? site?.language,
175
188
  localizeHref: props.localizeHref
176
189
  }
177
190
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-navigation",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,11 +16,12 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "hono": "^4.12.25",
19
- "@riebeckite/core": "0.0.24"
19
+ "@riebeckite/core": "0.0.26",
20
+ "@riebeckite/ui": "0.0.26"
20
21
  },
21
22
  "devDependencies": {
22
23
  "tsx": "^4.22.4",
23
- "@riebeckite/test": "0.0.24"
24
+ "@riebeckite/test": "0.0.26"
24
25
  },
25
26
  "publishConfig": {
26
27
  "access": "public"