@karaoke-cms/module-docs 0.14.0 → 0.15.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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/pages/doc.astro +26 -12
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@karaoke-cms/module-docs",
3
3
  "type": "module",
4
- "version": "0.14.0",
4
+ "version": "0.15.1",
5
5
  "description": "Docs module for karaoke-cms — documentation pages with sidebar navigation",
6
6
  "main": "./src/index.ts",
7
7
  "exports": {
@@ -23,13 +23,13 @@
23
23
  ],
24
24
  "peerDependencies": {
25
25
  "astro": ">=6.0.0",
26
- "@karaoke-cms/contracts": "^0.14.0"
26
+ "@karaoke-cms/contracts": "^0.15.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "astro": "^6.0.8",
30
30
  "vitest": "^4.1.1",
31
- "@karaoke-cms/astro": "0.14.0",
32
- "@karaoke-cms/contracts": "0.14.0"
31
+ "@karaoke-cms/astro": "0.15.1",
32
+ "@karaoke-cms/contracts": "0.15.1"
33
33
  },
34
34
  "scripts": {
35
35
  "test": "vitest run test/docs-factory.test.js"
@@ -1,9 +1,18 @@
1
1
  ---
2
- // TODO: use mount path from virtual module once mount-aware routing is implemented.
3
- // For now, mount is assumed to be /docs.
2
+ // NOTE: this is a reference implementation only it is NOT used as an injected route.
3
+ // The actual route entrypoint is generated by karaoke() into
4
+ // .astro/generated/karaoke-cms/{id}/doc.astro
5
+ // Keep this file in sync with generateDocPage() in:
6
+ // packages/astro/src/codegen/generate-docs-instance.ts
7
+ //
8
+ // Differences from the generated version:
9
+ // - mount is hardcoded to /docs (default instance only)
10
+ // - collection is hardcoded to 'docs'
11
+ // - multi-section switcher (docsSections) is omitted
4
12
  import { getCollection, render } from 'astro:content';
5
13
  import DefaultPage from '@karaoke-cms/astro/layouts/DefaultPage.astro';
6
14
  import ModuleLoader from '@karaoke-cms/astro/components/ModuleLoader.astro';
15
+ import DocsTree from '@karaoke-cms/astro/components/DocsTree.astro';
7
16
  import { resolveWikiImage } from '@karaoke-cms/astro';
8
17
 
9
18
  export async function getStaticPaths() {
@@ -17,23 +26,28 @@ export async function getStaticPaths() {
17
26
  const { entry } = Astro.props;
18
27
  const { Content } = await render(entry);
19
28
 
20
- // All docs for the sidebar, sorted alphabetically by title
21
29
  const allDocs = (await getCollection('docs', ({ data }) => data.publish === true))
22
30
  .sort((a, b) => a.data.title.localeCompare(b.data.title));
31
+
32
+ // Show the right sidebar only when the current entry is a directory (has child entries).
33
+ const isDirectory = allDocs.some(d => d.id.startsWith(entry.id + '/'));
23
34
  ---
24
35
 
25
36
  <DefaultPage title={entry.data.title} description={entry.data.description} type="article">
26
37
  <nav class="docs-sidebar" slot="left">
27
- <ul class="docs-sidebar-list">
28
- {allDocs.map(doc => (
29
- <li class="docs-sidebar-item">
30
- <a href={`/docs/${doc.id}`} aria-current={doc.id === entry.id ? 'page' : undefined}>
31
- {doc.data.title}
32
- </a>
33
- </li>
34
- ))}
35
- </ul>
38
+ <details class="docs-sidebar-wrap" open>
39
+ <summary class="docs-sidebar-toggle">Docs</summary>
40
+ <DocsTree entries={allDocs} currentId={entry.id} mount="/docs" />
41
+ </details>
36
42
  </nav>
43
+ {isDirectory && (
44
+ <aside class="docs-page-nav" slot="right">
45
+ <details class="docs-sidebar-wrap" open>
46
+ <summary class="docs-sidebar-toggle">In this section</summary>
47
+ <DocsTree entries={allDocs} currentId={entry.id} mount="/docs" rootPath={entry.id} maxDepth={1} />
48
+ </details>
49
+ </aside>
50
+ )}
37
51
  <article class="docs-article">
38
52
  {entry.data.featured_image && (
39
53
  <img src={resolveWikiImage(entry.data.featured_image)} alt="" class="docs-article-image" />