sourcey 3.5.0 → 3.5.1

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,6 +1,7 @@
1
1
  import type { NormalizedSpec } from "./types.js";
2
2
  import type { ResolvedTab } from "../config.js";
3
3
  import type { DocsPage } from "./markdown-loader.js";
4
+ import { type PrettyUrls } from "../site-url.js";
4
5
  export interface SiteNavigation {
5
6
  tabs: SiteTab[];
6
7
  activeTabSlug: string;
@@ -33,12 +34,12 @@ export interface SiteNavItem {
33
34
  * Introduction + Authentication → tag groups with operations → Models.
34
35
  * All hrefs are #anchor links (single-page spec rendering).
35
36
  */
36
- export declare function buildNavFromSpec(spec: NormalizedSpec, tabSlug: string): SiteTab;
37
+ export declare function buildNavFromSpec(spec: NormalizedSpec, tabSlug: string, prettyUrls?: PrettyUrls): SiteTab;
37
38
  /**
38
39
  * Build a navigation tab from markdown pages.
39
40
  * Groups come from the config; items come from loaded page data.
40
41
  */
41
- export declare function buildNavFromPages(tab: ResolvedTab, pagesByPath: Map<string, DocsPage>): SiteTab;
42
+ export declare function buildNavFromPages(tab: ResolvedTab, pagesByPath: Map<string, DocsPage>, prettyUrls?: PrettyUrls): SiteTab;
42
43
  /**
43
44
  * Assemble a SiteNavigation from a list of tabs.
44
45
  * Defaults to the first tab and first page as active.
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/core/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAOrD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,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AAgB/D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,UAAkB,GAC7B,OAAO,CAiDT;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EAClC,UAAU,GAAE,UAAkB,GAC7B,OAAO,CA6BT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,cAAc,CASnE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,cAAc,CAEhB"}
@@ -1,6 +1,16 @@
1
1
  import { tagNavigationLabel } from "./tag-utils.js";
2
- import { tabPath } from "../config.js";
2
+ import { pageOutputPath, tabPath } from "../config.js";
3
3
  import { htmlId } from "../utils/html-id.js";
4
+ import { toPublicPath } from "../site-url.js";
5
+ /**
6
+ * Convert a file output path (e.g. `concepts/index.html`) into the relative
7
+ * href the nav should emit, honouring the `prettyUrls` mode. The Sidebar
8
+ * prepends a `../` depth prefix at render time, so the value returned here
9
+ * must be root-relative *without* a leading slash.
10
+ */
11
+ function navHref(outputPath, prettyUrls) {
12
+ return toPublicPath(outputPath, "", prettyUrls).replace(/^\//, "");
13
+ }
4
14
  // ---------------------------------------------------------------------------
5
15
  // Builders
6
16
  // ---------------------------------------------------------------------------
@@ -10,8 +20,8 @@ import { htmlId } from "../utils/html-id.js";
10
20
  * Introduction + Authentication → tag groups with operations → Models.
11
21
  * All hrefs are #anchor links (single-page spec rendering).
12
22
  */
13
- export function buildNavFromSpec(spec, tabSlug) {
14
- const basePath = tabPath(tabSlug, "index.html");
23
+ export function buildNavFromSpec(spec, tabSlug, prettyUrls = false) {
24
+ const basePath = navHref(tabPath(tabSlug, "index.html"), prettyUrls);
15
25
  const groups = [];
16
26
  // Intro group
17
27
  const introItems = [
@@ -62,7 +72,7 @@ export function buildNavFromSpec(spec, tabSlug) {
62
72
  * Build a navigation tab from markdown pages.
63
73
  * Groups come from the config; items come from loaded page data.
64
74
  */
65
- export function buildNavFromPages(tab, pagesByPath) {
75
+ export function buildNavFromPages(tab, pagesByPath, prettyUrls = false) {
66
76
  const groups = [];
67
77
  if (tab.groups) {
68
78
  for (const group of tab.groups) {
@@ -73,7 +83,7 @@ export function buildNavFromPages(tab, pagesByPath) {
73
83
  continue;
74
84
  items.push({
75
85
  label: page.title,
76
- href: tabPath(tab.slug, `${page.slug}.html`),
86
+ href: navHref(pageOutputPath(tab.slug, page.slug, prettyUrls), prettyUrls),
77
87
  id: page.slug,
78
88
  });
79
89
  }
@@ -199,7 +199,7 @@ export async function startDevServer(options) {
199
199
  }
200
200
  const tab = config.tabs.find((candidate) => candidate.slug === content.tabSlug);
201
201
  if (tab) {
202
- const navTab = buildNavFromSpec(spec, tab.slug);
202
+ const navTab = buildNavFromSpec(spec, tab.slug, config.prettyUrls);
203
203
  navTab.label = tab.label;
204
204
  const idx = data.siteTabs.findIndex((candidate) => candidate.slug === content.tabSlug);
205
205
  if (idx !== -1)
@@ -222,7 +222,7 @@ export async function startDevServer(options) {
222
222
  }
223
223
  const tab = config.tabs.find((candidate) => candidate.slug === content.tabSlug);
224
224
  if (tab) {
225
- const navTab = buildNavFromSpec(spec, tab.slug);
225
+ const navTab = buildNavFromSpec(spec, tab.slug, config.prettyUrls);
226
226
  navTab.label = tab.label;
227
227
  const idx = data.siteTabs.findIndex((candidate) => candidate.slug === content.tabSlug);
228
228
  if (idx !== -1)
@@ -20,7 +20,7 @@ export async function assembleSite(config) {
20
20
  for (const tab of config.tabs) {
21
21
  if (tab.openapi || tab.mcp) {
22
22
  const spec = specsBySlug.get(tab.slug);
23
- const navTab = buildNavFromSpec(spec, tab.slug);
23
+ const navTab = buildNavFromSpec(spec, tab.slug, config.prettyUrls);
24
24
  navTab.label = tab.label;
25
25
  siteTabs.push(navTab);
26
26
  pageMap.set(tabPath(tab.slug, "index.html"), {
@@ -79,7 +79,7 @@ export async function assembleSite(config) {
79
79
  });
80
80
  }
81
81
  }
82
- siteTabs.push(buildNavFromPages(tab, pagesByPath));
82
+ siteTabs.push(buildNavFromPages(tab, pagesByPath, config.prettyUrls));
83
83
  }
84
84
  if (config.changelog.permalinks) {
85
85
  addPermalinkPages(pageMap);
@@ -130,7 +130,7 @@ export function rebuildMarkdownTabNavigation(pageMap, siteTabs, tabs, tabSlug, p
130
130
  }
131
131
  }
132
132
  }
133
- const navTab = buildNavFromPages(tab, pagesByPath);
133
+ const navTab = buildNavFromPages(tab, pagesByPath, prettyUrls);
134
134
  const idx = siteTabs.findIndex((candidate) => candidate.slug === tabSlug);
135
135
  if (idx !== -1)
136
136
  siteTabs[idx] = navTab;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sourcey",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Precision documentation from OpenAPI, MCP, Doxygen, and Markdown. Static HTML you own.",
5
5
  "type": "module",
6
6
  "engines": {