@riebeckite/plugin-docs 0.0.30 → 0.0.32

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/client.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // src/docs-sidebar.client.ts
2
2
  var COLLAPSIBLE_PROPERTY = "--rb-docs-sidebar-collapsible";
3
- function initDocsSidebar() {
3
+ function initDocsSidebar(context = {}) {
4
+ const root = context.root ?? document;
4
5
  const details = Array.from(
5
- document.querySelectorAll(
6
- "[data-docs-sidebar-details]"
7
- )
6
+ root.querySelectorAll("[data-docs-sidebar-details]")
8
7
  );
9
8
  const first = details[0];
10
9
  if (!first) return;
@@ -22,6 +21,7 @@ function initDocsSidebar() {
22
21
  apply(next);
23
22
  };
24
23
  window.addEventListener("resize", sync, { passive: true });
24
+ return () => window.removeEventListener("resize", sync);
25
25
  }
26
26
  function isCollapsible(element) {
27
27
  return getComputedStyle(element).getPropertyValue(COLLAPSIBLE_PROPERTY).trim() !== "0";
@@ -150,11 +150,11 @@ function titleFromSegment(segment) {
150
150
  }
151
151
 
152
152
  // src/data.ts
153
- var getDocsNavigation = ({ view, entrySlug, options }) => {
153
+ var getDocsNavigation = ({ view, entries, entrySlug, options }) => {
154
154
  const entry = view.findRoutableBySlug(entrySlug);
155
155
  if (!entry) return [];
156
- const localized = view.discoverableEntries.filter(
157
- (candidate) => candidate.publicLocation.language === entry.publicLocation.language
156
+ const localized = entries.filter(
157
+ (candidate) => candidate.publishing.discoverable && candidate.publicLocation.language === entry.publicLocation.language
158
158
  );
159
159
  return buildDocsNavigation(localized, resolveDocsOptions(options));
160
160
  };
@@ -167,6 +167,7 @@ var DocsSidebar = (async (props) => {
167
167
  const options = findDocsOptions(site?.config.plugins);
168
168
  const items = props.items ?? (site && article?.entry && options ? await getDocsNavigation({
169
169
  view: site.view,
170
+ entries: site.manifest.discoverableEntries,
170
171
  entrySlug: article.entry.slug,
171
172
  options
172
173
  }) : []);
package/dist/index.js CHANGED
@@ -163,11 +163,11 @@ import { useArticleContext, useSiteContext } from "@riebeckite/ui";
163
163
  import { html } from "hono/html";
164
164
 
165
165
  // src/data.ts
166
- var getDocsNavigation = ({ view, entrySlug, options }) => {
166
+ var getDocsNavigation = ({ view, entries, entrySlug, options }) => {
167
167
  const entry = view.findRoutableBySlug(entrySlug);
168
168
  if (!entry) return [];
169
- const localized = view.discoverableEntries.filter(
170
- (candidate) => candidate.publicLocation.language === entry.publicLocation.language
169
+ const localized = entries.filter(
170
+ (candidate) => candidate.publishing.discoverable && candidate.publicLocation.language === entry.publicLocation.language
171
171
  );
172
172
  return buildDocsNavigation(localized, resolveDocsOptions(options));
173
173
  };
@@ -189,6 +189,7 @@ var DocsPrevNext = (async (props) => {
189
189
  const options = findDocsOptions(site?.config.plugins);
190
190
  const navigation = site && article?.entry && options ? await getDocsNavigation({
191
191
  view: site.view,
192
+ entries: site.manifest.discoverableEntries,
192
193
  entrySlug: article.entry.slug,
193
194
  options
194
195
  }) : [];
@@ -252,6 +253,7 @@ var DocsSidebar = (async (props) => {
252
253
  const options = findDocsOptions2(site?.config.plugins);
253
254
  const items = props.items ?? (site && article?.entry && options ? await getDocsNavigation({
254
255
  view: site.view,
256
+ entries: site.manifest.discoverableEntries,
255
257
  entrySlug: article.entry.slug,
256
258
  options
257
259
  }) : []);
@@ -342,11 +344,10 @@ function findDocsOptions2(plugins) {
342
344
 
343
345
  // src/docs-sidebar.client.ts
344
346
  var COLLAPSIBLE_PROPERTY = "--rb-docs-sidebar-collapsible";
345
- function initDocsSidebar() {
347
+ function initDocsSidebar(context = {}) {
348
+ const root = context.root ?? document;
346
349
  const details = Array.from(
347
- document.querySelectorAll(
348
- "[data-docs-sidebar-details]"
349
- )
350
+ root.querySelectorAll("[data-docs-sidebar-details]")
350
351
  );
351
352
  const first = details[0];
352
353
  if (!first) return;
@@ -364,6 +365,7 @@ function initDocsSidebar() {
364
365
  apply(next);
365
366
  };
366
367
  window.addEventListener("resize", sync, { passive: true });
368
+ return () => window.removeEventListener("resize", sync);
367
369
  }
368
370
  function isCollapsible(element) {
369
371
  return getComputedStyle(element).getPropertyValue(COLLAPSIBLE_PROPERTY).trim() !== "0";
@@ -453,7 +455,10 @@ function docs(options) {
453
455
  createClientEntry(
454
456
  DOCS_PLUGIN_NAME,
455
457
  "@riebeckite/plugin-docs/client",
456
- "initDocsSidebar"
458
+ "initDocsSidebar",
459
+ void 0,
460
+ void 0,
461
+ "context"
457
462
  )
458
463
  ]
459
464
  });
@@ -1,7 +1,8 @@
1
- import type { PluginDataHelper, PublicContentView } from "@riebeckite/core";
1
+ import type { ContentManifestEntry, PluginDataHelper, PublicContentView } from "@riebeckite/core";
2
2
  import type { DocsNavigationItem, DocsNavigationLink, DocsOptions } from "./types.js";
3
3
  export declare const getDocsNavigation: PluginDataHelper<{
4
4
  view: PublicContentView;
5
+ entries: readonly ContentManifestEntry[];
5
6
  entrySlug: string;
6
7
  options: DocsOptions;
7
8
  }, readonly DocsNavigationItem[]>;
@@ -1 +1,5 @@
1
- export declare function initDocsSidebar(): void;
1
+ type ClientContext = {
2
+ root?: ParentNode;
3
+ };
4
+ export declare function initDocsSidebar(context?: ClientContext): () => void;
5
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-docs",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,12 +28,12 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "hono": "^4.12.25",
31
- "@riebeckite/core": "0.0.30",
32
- "@riebeckite/ui": "0.0.30"
31
+ "@riebeckite/core": "0.0.32",
32
+ "@riebeckite/ui": "0.0.32"
33
33
  },
34
34
  "devDependencies": {
35
35
  "tsx": "^4.22.4",
36
- "@riebeckite/test": "0.0.30"
36
+ "@riebeckite/test": "0.0.32"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"