specra 0.2.66 → 0.2.68
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/config/category.schema.json +58 -0
- package/dist/badges.d.ts +38 -0
- package/dist/badges.js +109 -0
- package/dist/category.d.ts +2 -0
- package/dist/changelog-context.d.ts +6 -0
- package/dist/changelog-context.js +15 -0
- package/dist/changelog.d.ts +59 -0
- package/dist/changelog.js +204 -0
- package/dist/components/docs/Changelog.svelte +71 -0
- package/dist/components/docs/Changelog.svelte.d.ts +14 -0
- package/dist/components/docs/Sidebar.svelte +3 -0
- package/dist/components/docs/Sidebar.svelte.d.ts +3 -0
- package/dist/components/docs/SidebarBadge.svelte +15 -0
- package/dist/components/docs/SidebarBadge.svelte.d.ts +7 -0
- package/dist/components/docs/SidebarMenuItems.svelte +50 -12
- package/dist/components/docs/SidebarMenuItems.svelte.d.ts +3 -0
- package/dist/components/docs/Update.svelte +75 -0
- package/dist/components/docs/Update.svelte.d.ts +19 -0
- package/dist/components/docs/index.d.ts +3 -0
- package/dist/components/docs/index.js +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/mdx-components.d.ts +2 -2
- package/dist/mdx-components.js +4 -2
- package/dist/mdx.d.ts +5 -0
- package/dist/mdx.js +153 -17
- package/dist/rehype-changelog-ids.d.ts +20 -0
- package/dist/rehype-changelog-ids.js +43 -0
- package/dist/sidebar-utils.d.ts +3 -0
- package/dist/sidebar-utils.js +5 -1
- package/package.json +2 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import GithubSlugger from 'github-slugger';
|
|
2
|
+
const HEADING_TAG = /^h[1-6]$/;
|
|
3
|
+
/** Concatenate the text nodes beneath a node, as hast-util-to-string would. */
|
|
4
|
+
function textContent(node) {
|
|
5
|
+
if (node.type === 'text')
|
|
6
|
+
return String(node.value ?? '');
|
|
7
|
+
if (Array.isArray(node.children))
|
|
8
|
+
return node.children.map(textContent).join('');
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
/** Preorder walk over element nodes, i.e. document order. */
|
|
12
|
+
function walkElements(nodes, fn) {
|
|
13
|
+
for (const node of nodes) {
|
|
14
|
+
if (node.type !== 'element')
|
|
15
|
+
continue;
|
|
16
|
+
fn(node);
|
|
17
|
+
if (node.children) {
|
|
18
|
+
walkElements(node.children, fn);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function rehypeChangelogIds() {
|
|
23
|
+
return (tree) => {
|
|
24
|
+
const slugger = new GithubSlugger();
|
|
25
|
+
walkElements(tree.children, (node) => {
|
|
26
|
+
// Consume the name rehype-slug already consumed for this heading, keeping
|
|
27
|
+
// the two occurrence counters aligned. The return value is discarded —
|
|
28
|
+
// rehype-slug owns the heading's actual id.
|
|
29
|
+
if (HEADING_TAG.test(node.tagName)) {
|
|
30
|
+
slugger.slug(textContent(node));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (node.tagName !== 'update')
|
|
34
|
+
return;
|
|
35
|
+
const label = node.properties?.label;
|
|
36
|
+
// A label-less update has no identity to anchor. It still renders; it just
|
|
37
|
+
// gets no anchor, no ToC entry and no feed item.
|
|
38
|
+
if (typeof label !== 'string' || !label.trim())
|
|
39
|
+
return;
|
|
40
|
+
node.properties = { ...node.properties, id: slugger.slug(label.trim()) };
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
package/dist/sidebar-utils.d.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* This module provides consistent sidebar logic across the application
|
|
4
4
|
* to ensure ordering is handled the same way everywhere.
|
|
5
5
|
*/
|
|
6
|
+
import type { BadgeInput } from "./badges.js";
|
|
6
7
|
export interface SidebarGroup {
|
|
7
8
|
label: string;
|
|
8
9
|
path: string;
|
|
9
10
|
icon?: string;
|
|
11
|
+
badge?: BadgeInput;
|
|
10
12
|
items: any[];
|
|
11
13
|
position: number;
|
|
12
14
|
collapsible: boolean;
|
|
@@ -50,6 +52,7 @@ export declare function buildSidebarStructure<T extends {
|
|
|
50
52
|
categoryLabel?: string;
|
|
51
53
|
categoryPosition?: number;
|
|
52
54
|
categoryIcon?: string;
|
|
55
|
+
categoryBadge?: BadgeInput;
|
|
53
56
|
categoryCollapsible?: boolean;
|
|
54
57
|
categoryCollapsed?: boolean;
|
|
55
58
|
meta: any;
|
package/dist/sidebar-utils.js
CHANGED
|
@@ -49,11 +49,14 @@ export function buildSidebarStructure(docs) {
|
|
|
49
49
|
docs.forEach((doc) => {
|
|
50
50
|
const pathParts = doc.filePath.split("/");
|
|
51
51
|
const folderPath = pathParts.length > 1 ? pathParts.slice(0, -1).join("/") : "";
|
|
52
|
-
|
|
52
|
+
// A `_category_.json` may set a badge without setting a label, so keying
|
|
53
|
+
// this purely off `categoryLabel` would silently drop the badge.
|
|
54
|
+
if (folderPath && (doc.categoryLabel || doc.categoryBadge)) {
|
|
53
55
|
categoryMetadata.set(folderPath, {
|
|
54
56
|
label: doc.categoryLabel,
|
|
55
57
|
position: doc.categoryPosition,
|
|
56
58
|
icon: doc.categoryIcon,
|
|
59
|
+
badge: doc.categoryBadge,
|
|
57
60
|
collapsible: doc.categoryCollapsible,
|
|
58
61
|
collapsed: doc.categoryCollapsed
|
|
59
62
|
});
|
|
@@ -100,6 +103,7 @@ export function buildSidebarStructure(docs) {
|
|
|
100
103
|
label: metadata?.label ?? folderLabel,
|
|
101
104
|
path: currentPath,
|
|
102
105
|
icon: metadata?.icon,
|
|
106
|
+
badge: metadata?.badge,
|
|
103
107
|
items: [],
|
|
104
108
|
position: metadata?.position ?? 999,
|
|
105
109
|
collapsible: metadata?.collapsible ?? true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.68",
|
|
4
4
|
"description": "A modern documentation library for SvelteKit with built-in versioning, API reference generation, full-text search, and MDX support",
|
|
5
5
|
"svelte": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"clsx": "^2.1.1",
|
|
82
82
|
"date-fns": "^4.1.0",
|
|
83
83
|
"embla-carousel-svelte": "^8.5.1",
|
|
84
|
+
"github-slugger": "^2.0.0",
|
|
84
85
|
"gray-matter": "^4.0.3",
|
|
85
86
|
"hast-util-to-html": "^9.0.0",
|
|
86
87
|
"js-yaml": "^4.1.1",
|