@unterberg/nivel 0.1.4 → 0.1.6
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/README.md +162 -68
- package/dist/{chunk-5NW6G3SG.js → chunk-5QP3Y2DU.js} +465 -378
- package/dist/chunk-5QP3Y2DU.js.map +1 -0
- package/dist/{chunk-YQFALPGR.js → chunk-6665M66K.js} +20 -5
- package/dist/chunk-6665M66K.js.map +1 -0
- package/dist/{chunk-SJDXMQ43.js → chunk-INTDB5VE.js} +3 -3
- package/dist/{chunk-SJDXMQ43.js.map → chunk-INTDB5VE.js.map} +1 -1
- package/dist/{chunk-5YLY5ROG.js → chunk-QVIL3FKM.js} +2 -2
- package/dist/{chunk-Q7JU4J6A.js → chunk-YHV6L37L.js} +87 -58
- package/dist/chunk-YHV6L37L.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/client.d.ts +25 -5
- package/dist/client.js +7 -1
- package/dist/index.js +1 -1
- package/dist/mdx/code-blocks.d.ts +40 -6
- package/dist/mdx/code-blocks.js +1 -1
- package/dist/mdx.d.ts +1 -3
- package/dist/mdx.js +1 -1
- package/dist/mdx.js.map +1 -1
- package/dist/runtime/client.d.ts +1 -1
- package/dist/runtime/client.js +7 -1
- package/dist/runtime/node.js +2 -2
- package/dist/vike.js +16 -32
- package/dist/vike.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-5NW6G3SG.js.map +0 -1
- package/dist/chunk-Q7JU4J6A.js.map +0 -1
- package/dist/chunk-YQFALPGR.js.map +0 -1
- /package/dist/{chunk-5YLY5ROG.js.map → chunk-QVIL3FKM.js.map} +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -2,14 +2,15 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, ComponentType } from 'react';
|
|
4
4
|
import * as _classmatejs_react from '@classmatejs/react';
|
|
5
|
-
import { g as DocsConfig, T as ThemePreference, r as DocsThemeConfig } from './types-BGAec0JI.js';
|
|
5
|
+
import { g as DocsConfig, a as DocPageData, D as DocHeading, T as ThemePreference, r as DocsThemeConfig } from './types-BGAec0JI.js';
|
|
6
6
|
import * as zustand_middleware from 'zustand/middleware';
|
|
7
7
|
import * as zustand from 'zustand';
|
|
8
8
|
|
|
9
9
|
interface AppLayoutProps {
|
|
10
10
|
children: ReactNode;
|
|
11
|
+
header?: ReactNode;
|
|
11
12
|
}
|
|
12
|
-
declare const AppLayout: ({ children }: AppLayoutProps) => react_jsx_runtime.JSX.Element;
|
|
13
|
+
declare const AppLayout: ({ children, header }: AppLayoutProps) => react_jsx_runtime.JSX.Element;
|
|
13
14
|
|
|
14
15
|
declare const LayoutSize: {
|
|
15
16
|
readonly xxs: "xxs";
|
|
@@ -40,6 +41,11 @@ interface DocsPageProps {
|
|
|
40
41
|
}
|
|
41
42
|
declare const DocsPage: ({ Content }: DocsPageProps) => react_jsx_runtime.JSX.Element;
|
|
42
43
|
|
|
44
|
+
interface DocsRouteLayoutProps {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
declare const DocsRouteLayout: ({ children }: DocsRouteLayoutProps) => react_jsx_runtime.JSX.Element;
|
|
48
|
+
|
|
43
49
|
type DocsSearchState = {
|
|
44
50
|
isOpen: boolean;
|
|
45
51
|
query: string;
|
|
@@ -54,18 +60,32 @@ type DocsSearchActions = {
|
|
|
54
60
|
type DocsSearchSlice = DocsSearchState & DocsSearchActions;
|
|
55
61
|
type DocsSidebarState = {
|
|
56
62
|
openNodes: Record<string, boolean>;
|
|
57
|
-
scrollTop: number;
|
|
58
63
|
};
|
|
59
64
|
type DocsSidebarActions = {
|
|
60
65
|
setNodeOpen: (nodeId: string, isOpen: boolean) => void;
|
|
61
|
-
setScrollTop: (scrollTop: number) => void;
|
|
62
66
|
};
|
|
63
67
|
type DocsSidebarSlice = DocsSidebarState & DocsSidebarActions;
|
|
68
|
+
type DocsRouteState = {
|
|
69
|
+
currentHref: string;
|
|
70
|
+
currentSectionId: string | null;
|
|
71
|
+
pageTitle: string;
|
|
72
|
+
headings: DocHeading[];
|
|
73
|
+
tableOfContents: boolean;
|
|
74
|
+
previousPage: DocPageData['previousPage'];
|
|
75
|
+
nextPage: DocPageData['nextPage'];
|
|
76
|
+
};
|
|
77
|
+
type DocsRouteActions = {
|
|
78
|
+
setPageData: (data: DocPageData) => void;
|
|
79
|
+
clearPageData: () => void;
|
|
80
|
+
};
|
|
81
|
+
type DocsRouteSlice = DocsRouteState & DocsRouteActions;
|
|
64
82
|
|
|
65
83
|
declare const useDocsSearchStore: <Selected>(selector: (state: DocsSearchSlice) => Selected) => Selected;
|
|
66
84
|
declare const useDocsSearchActions: () => DocsSearchActions;
|
|
67
85
|
declare const useDocsSidebarStore: <Selected>(selector: (state: DocsSidebarSlice) => Selected) => Selected;
|
|
68
86
|
declare const useDocsSidebarActions: () => DocsSidebarActions;
|
|
87
|
+
declare const useDocsRouteStore: <Selected>(selector: (state: DocsRouteSlice) => Selected) => Selected;
|
|
88
|
+
declare const useDocsRouteActions: () => DocsRouteActions;
|
|
69
89
|
|
|
70
90
|
type DocsUserSettingsState = {
|
|
71
91
|
codeBlockChoices: Record<string, string>;
|
|
@@ -90,4 +110,4 @@ declare const useDocsUserSettingsStore: zustand.UseBoundStore<Omit<zustand.Store
|
|
|
90
110
|
declare const DEFAULT_THEME_PREFERENCE: ThemePreference;
|
|
91
111
|
declare const applyThemePreference: (themePreference: ThemePreference | null | undefined, themeConfig: Required<DocsThemeConfig>) => void;
|
|
92
112
|
|
|
93
|
-
export { AppLayout, DEFAULT_THEME_PREFERENCE, DocsPage, type DocsSearchActions, type DocsSearchSlice, type DocsSearchState, type DocsSidebarActions, type DocsSidebarSlice, type DocsSidebarState, LayoutComponent, MetaHead, ProseContainer, UserSettingsSync, applyThemePreference, useDocsSearchActions, useDocsSearchStore, useDocsSidebarActions, useDocsSidebarStore, useDocsUserSettingsStore };
|
|
113
|
+
export { AppLayout, DEFAULT_THEME_PREFERENCE, DocsPage, type DocsRouteActions, DocsRouteLayout, type DocsRouteSlice, type DocsRouteState, type DocsSearchActions, type DocsSearchSlice, type DocsSearchState, type DocsSidebarActions, type DocsSidebarSlice, type DocsSidebarState, LayoutComponent, MetaHead, ProseContainer, UserSettingsSync, applyThemePreference, useDocsRouteActions, useDocsRouteStore, useDocsSearchActions, useDocsSearchStore, useDocsSidebarActions, useDocsSidebarStore, useDocsUserSettingsStore };
|
package/dist/client.js
CHANGED
|
@@ -2,17 +2,20 @@ import {
|
|
|
2
2
|
AppLayout,
|
|
3
3
|
DEFAULT_THEME_PREFERENCE,
|
|
4
4
|
DocsPage,
|
|
5
|
+
DocsRouteLayout,
|
|
5
6
|
LayoutComponent,
|
|
6
7
|
MetaHead,
|
|
7
8
|
ProseContainer,
|
|
8
9
|
UserSettingsSync,
|
|
9
10
|
applyThemePreference,
|
|
11
|
+
useDocsRouteActions,
|
|
12
|
+
useDocsRouteStore,
|
|
10
13
|
useDocsSearchActions,
|
|
11
14
|
useDocsSearchStore,
|
|
12
15
|
useDocsSidebarActions,
|
|
13
16
|
useDocsSidebarStore,
|
|
14
17
|
useDocsUserSettingsStore
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5QP3Y2DU.js";
|
|
16
19
|
import "./chunk-SOVTSE5J.js";
|
|
17
20
|
import "./chunk-L6ZVB6XH.js";
|
|
18
21
|
import "./chunk-NDJ5LYLK.js";
|
|
@@ -20,11 +23,14 @@ export {
|
|
|
20
23
|
AppLayout,
|
|
21
24
|
DEFAULT_THEME_PREFERENCE,
|
|
22
25
|
DocsPage,
|
|
26
|
+
DocsRouteLayout,
|
|
23
27
|
LayoutComponent,
|
|
24
28
|
MetaHead,
|
|
25
29
|
ProseContainer,
|
|
26
30
|
UserSettingsSync,
|
|
27
31
|
applyThemePreference,
|
|
32
|
+
useDocsRouteActions,
|
|
33
|
+
useDocsRouteStore,
|
|
28
34
|
useDocsSearchActions,
|
|
29
35
|
useDocsSearchStore,
|
|
30
36
|
useDocsSidebarActions,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
+
import * as rehypePrettyCode from 'rehype-pretty-code';
|
|
2
|
+
import rehypePrettyCode__default from 'rehype-pretty-code';
|
|
3
|
+
import remarkDirective from 'remark-directive';
|
|
1
4
|
import { ShikiTransformer } from 'shiki';
|
|
2
5
|
|
|
6
|
+
type ChoiceData = {
|
|
7
|
+
customDataChoice?: string | undefined;
|
|
8
|
+
customDataFilter?: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
interface AstNode {
|
|
11
|
+
type: string;
|
|
12
|
+
data?: ChoiceData | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface ParentNode<Child extends AstNode = AstNode> extends AstNode {
|
|
15
|
+
children: Child[];
|
|
16
|
+
}
|
|
17
|
+
interface RootNode extends ParentNode {
|
|
18
|
+
type: 'root';
|
|
19
|
+
}
|
|
20
|
+
interface FileLike {
|
|
21
|
+
path?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface TextNode extends AstNode {
|
|
24
|
+
type: 'text';
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
type ElementContentNode = ElementNode | TextNode;
|
|
28
|
+
interface ElementNode extends ParentNode<ElementContentNode> {
|
|
29
|
+
type: 'element';
|
|
30
|
+
tagName: string;
|
|
31
|
+
properties: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
interface HtmlRootNode extends ParentNode<ElementContentNode> {
|
|
34
|
+
type: 'root';
|
|
35
|
+
}
|
|
36
|
+
|
|
3
37
|
type ParsedMeta<Name extends string = string> = {
|
|
4
38
|
props: Partial<Record<Name, string>>;
|
|
5
39
|
rest: string;
|
|
@@ -19,19 +53,19 @@ declare const getCodeBlockPropsFromMeta: (meta: unknown) => {
|
|
|
19
53
|
title: string | null;
|
|
20
54
|
};
|
|
21
55
|
|
|
22
|
-
declare const rehypeMetaToProps: () => (tree:
|
|
56
|
+
declare const rehypeMetaToProps: () => (tree: HtmlRootNode) => void;
|
|
23
57
|
|
|
24
|
-
declare const remarkChoiceGroup: () => (tree:
|
|
58
|
+
declare const remarkChoiceGroup: () => (tree: RootNode) => void;
|
|
25
59
|
|
|
26
|
-
declare const remarkDetype: () => (tree:
|
|
60
|
+
declare const remarkDetype: () => (tree: RootNode, file: FileLike) => Promise<void>;
|
|
27
61
|
|
|
28
|
-
declare const remarkPkgManager: () => (tree:
|
|
62
|
+
declare const remarkPkgManager: () => (tree: RootNode) => void;
|
|
29
63
|
|
|
30
64
|
declare const shikiTransformerAutoLinks: () => ShikiTransformer;
|
|
31
65
|
|
|
32
66
|
declare const getCodeBlockMdxPlugins: () => {
|
|
33
|
-
remarkPlugins:
|
|
34
|
-
rehypePlugins:
|
|
67
|
+
remarkPlugins: (typeof remarkDirective | (() => (tree: RootNode, file: FileLike) => Promise<void>) | (() => (tree: RootNode) => void))[];
|
|
68
|
+
rehypePlugins: ([typeof rehypePrettyCode__default, rehypePrettyCode.Options | undefined] | (() => (tree: HtmlRootNode) => void))[];
|
|
35
69
|
};
|
|
36
70
|
|
|
37
71
|
export { getCodeBlockMdxPlugins, getCodeBlockPropsFromMeta, parseMetaString, rehypeMetaToProps, remarkChoiceGroup, remarkDetype, remarkPkgManager, shikiTransformerAutoLinks, stripMetaProps };
|
package/dist/mdx/code-blocks.js
CHANGED
package/dist/mdx.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type MdxComponents = Record<string, ComponentType<any> | string>;
|
|
1
|
+
type MdxComponents = Record<string, unknown>;
|
|
4
2
|
declare const useMDXComponents: (components?: MdxComponents) => MdxComponents;
|
|
5
3
|
|
|
6
4
|
export { useMDXComponents };
|
package/dist/mdx.js
CHANGED
package/dist/mdx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mdx/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/mdx/index.ts"],"sourcesContent":["import {\n Alert,\n ChoiceGroup,\n CodeBlockTransformer,\n FileAdded,\n FileRemoved,\n Link,\n Overview,\n Pre,\n RepoLink,\n Table,\n} from '../index.js'\n\ntype MdxComponents = Record<string, unknown>\n\nexport const useMDXComponents = (components?: MdxComponents): MdxComponents => {\n return {\n Alert,\n Link,\n RepoLink,\n Table,\n Overview,\n ChoiceGroup,\n CodeBlockTransformer,\n FileAdded,\n FileRemoved,\n pre: Pre,\n ...components,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAeO,IAAM,mBAAmB,CAAC,eAA8C;AAC7E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,GAAG;AAAA,EACL;AACF;","names":[]}
|
package/dist/runtime/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AppLayout, DEFAULT_THEME_PREFERENCE, DocsPage, DocsSearchActions, DocsSearchSlice, DocsSearchState, DocsSidebarActions, DocsSidebarSlice, DocsSidebarState, LayoutComponent, MetaHead, ProseContainer, UserSettingsSync, applyThemePreference, useDocsSearchActions, useDocsSearchStore, useDocsSidebarActions, useDocsSidebarStore, useDocsUserSettingsStore } from '../client.js';
|
|
1
|
+
export { AppLayout, DEFAULT_THEME_PREFERENCE, DocsPage, DocsRouteActions, DocsRouteLayout, DocsRouteSlice, DocsRouteState, DocsSearchActions, DocsSearchSlice, DocsSearchState, DocsSidebarActions, DocsSidebarSlice, DocsSidebarState, LayoutComponent, MetaHead, ProseContainer, UserSettingsSync, applyThemePreference, useDocsRouteActions, useDocsRouteStore, useDocsSearchActions, useDocsSearchStore, useDocsSidebarActions, useDocsSidebarStore, useDocsUserSettingsStore } from '../client.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@classmatejs/react';
|
package/dist/runtime/client.js
CHANGED
|
@@ -2,17 +2,20 @@ import {
|
|
|
2
2
|
AppLayout,
|
|
3
3
|
DEFAULT_THEME_PREFERENCE,
|
|
4
4
|
DocsPage,
|
|
5
|
+
DocsRouteLayout,
|
|
5
6
|
LayoutComponent,
|
|
6
7
|
MetaHead,
|
|
7
8
|
ProseContainer,
|
|
8
9
|
UserSettingsSync,
|
|
9
10
|
applyThemePreference,
|
|
11
|
+
useDocsRouteActions,
|
|
12
|
+
useDocsRouteStore,
|
|
10
13
|
useDocsSearchActions,
|
|
11
14
|
useDocsSearchStore,
|
|
12
15
|
useDocsSidebarActions,
|
|
13
16
|
useDocsSidebarStore,
|
|
14
17
|
useDocsUserSettingsStore
|
|
15
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-5QP3Y2DU.js";
|
|
16
19
|
import "../chunk-SOVTSE5J.js";
|
|
17
20
|
import "../chunk-L6ZVB6XH.js";
|
|
18
21
|
import "../chunk-NDJ5LYLK.js";
|
|
@@ -20,11 +23,14 @@ export {
|
|
|
20
23
|
AppLayout,
|
|
21
24
|
DEFAULT_THEME_PREFERENCE,
|
|
22
25
|
DocsPage,
|
|
26
|
+
DocsRouteLayout,
|
|
23
27
|
LayoutComponent,
|
|
24
28
|
MetaHead,
|
|
25
29
|
ProseContainer,
|
|
26
30
|
UserSettingsSync,
|
|
27
31
|
applyThemePreference,
|
|
32
|
+
useDocsRouteActions,
|
|
33
|
+
useDocsRouteStore,
|
|
28
34
|
useDocsSearchActions,
|
|
29
35
|
useDocsSearchStore,
|
|
30
36
|
useDocsSidebarActions,
|
package/dist/runtime/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
nivelPagesPlugin
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-QVIL3FKM.js";
|
|
4
4
|
import {
|
|
5
5
|
getGeneratedPagesRoot,
|
|
6
6
|
getInitSummary,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
initConsumer,
|
|
9
9
|
loadDocsConfig,
|
|
10
10
|
syncGeneratedDocsPages
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-6665M66K.js";
|
|
12
12
|
import "../chunk-SOVTSE5J.js";
|
|
13
13
|
import {
|
|
14
14
|
getResolvedPageById,
|
package/dist/vike.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
nivelPagesPlugin
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-QVIL3FKM.js";
|
|
4
|
+
import "./chunk-6665M66K.js";
|
|
5
5
|
import {
|
|
6
6
|
createHeadingSlugger,
|
|
7
7
|
normalizeHeadingTitle
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import "./chunk-NDJ5LYLK.js";
|
|
10
10
|
import {
|
|
11
11
|
getCodeBlockMdxPlugins
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-YHV6L37L.js";
|
|
13
13
|
|
|
14
14
|
// src/vike/index.ts
|
|
15
15
|
import mdx from "@mdx-js/rollup";
|
|
@@ -19,13 +19,10 @@ import remarkGfm from "remark-gfm";
|
|
|
19
19
|
import { visit } from "unist-util-visit";
|
|
20
20
|
var headingTags = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
21
21
|
var getNodeText = (node) => {
|
|
22
|
-
if (!node || typeof node !== "object") {
|
|
23
|
-
return "";
|
|
24
|
-
}
|
|
25
22
|
if (node.type === "text") {
|
|
26
23
|
return typeof node.value === "string" ? node.value : "";
|
|
27
24
|
}
|
|
28
|
-
if (
|
|
25
|
+
if ("children" in node) {
|
|
29
26
|
return node.children.map((child) => getNodeText(child)).join("");
|
|
30
27
|
}
|
|
31
28
|
return "";
|
|
@@ -39,6 +36,14 @@ var getClassNames = (value) => {
|
|
|
39
36
|
}
|
|
40
37
|
return [];
|
|
41
38
|
};
|
|
39
|
+
var createLinkIconLine = (x1, y1, x2, y2) => {
|
|
40
|
+
return {
|
|
41
|
+
type: "element",
|
|
42
|
+
tagName: "line",
|
|
43
|
+
properties: { x1, y1, x2, y2 },
|
|
44
|
+
children: []
|
|
45
|
+
};
|
|
46
|
+
};
|
|
42
47
|
var rehypeDocsHeadings = () => {
|
|
43
48
|
return (tree) => {
|
|
44
49
|
const slugify = createHeadingSlugger();
|
|
@@ -93,30 +98,10 @@ var rehypeDocsHeadings = () => {
|
|
|
93
98
|
className: ["w-4 h-4 hidden group-hover:block translate-x-5"]
|
|
94
99
|
},
|
|
95
100
|
children: [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
children: []
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: "element",
|
|
104
|
-
tagName: "line",
|
|
105
|
-
properties: { x1: 4, y1: 15, x2: 20, y2: 15 },
|
|
106
|
-
children: []
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: "element",
|
|
110
|
-
tagName: "line",
|
|
111
|
-
properties: { x1: 10, y1: 3, x2: 8, y2: 21 },
|
|
112
|
-
children: []
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
type: "element",
|
|
116
|
-
tagName: "line",
|
|
117
|
-
properties: { x1: 16, y1: 3, x2: 14, y2: 21 },
|
|
118
|
-
children: []
|
|
119
|
-
}
|
|
101
|
+
createLinkIconLine(4, 9, 20, 9),
|
|
102
|
+
createLinkIconLine(4, 15, 20, 15),
|
|
103
|
+
createLinkIconLine(10, 3, 8, 21),
|
|
104
|
+
createLinkIconLine(16, 3, 14, 21)
|
|
120
105
|
]
|
|
121
106
|
}
|
|
122
107
|
]
|
|
@@ -176,7 +161,6 @@ var createNivelVikeConfig = (docsConfig) => {
|
|
|
176
161
|
htmlAttributes: {
|
|
177
162
|
"data-theme": getDefaultConsumerDataTheme(docsConfig)
|
|
178
163
|
},
|
|
179
|
-
passToClient: ["docs"],
|
|
180
164
|
prerender: true
|
|
181
165
|
};
|
|
182
166
|
};
|
package/dist/vike.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vike/index.ts","../src/mdx/plugins/rehypeDocsHeadings.ts"],"sourcesContent":["export { nivelConfig as default }\n\nimport mdx from '@mdx-js/rollup'\nimport remarkGfm from 'remark-gfm'\nimport type { Config } from 'vike/types'\nimport type { PluginOption, UserConfig } from 'vite'\nimport type { DocsConfig } from '../docs/types.js'\nimport { getCodeBlockMdxPlugins } from '../mdx/code-blocks/index.js'\nimport { rehypeDocsHeadings } from '../mdx/plugins/rehypeDocsHeadings.js'\nimport { nivelPagesPlugin } from '../runtime/node/index.js'\n\nprocess.env.VIKE_CRAWL ??= JSON.stringify({ git: false })\n\nconst codeBlockMdxPlugins = getCodeBlockMdxPlugins()\n\nconst viteConfig: UserConfig = {\n plugins: [\n {\n ...mdx({\n providerImportSource: '@unterberg/nivel/mdx',\n ...codeBlockMdxPlugins,\n rehypePlugins: [...codeBlockMdxPlugins.rehypePlugins, rehypeDocsHeadings],\n remarkPlugins: [remarkGfm, ...codeBlockMdxPlugins.remarkPlugins],\n }),\n enforce: 'pre',\n } as PluginOption,\n nivelPagesPlugin(),\n ],\n ssr: {\n noExternal: ['@unterberg/nivel'],\n },\n}\n\nconst getDefaultConsumerDataTheme = (docsConfig: DocsConfig) => {\n const defaultPreference = docsConfig.theme?.defaultPreference ?? 'light'\n const lightThemeName = docsConfig.theme?.light ?? 'consumer-light'\n const darkThemeName = docsConfig.theme?.dark ?? 'consumer-dark'\n\n return defaultPreference === 'dark' ? darkThemeName : lightThemeName\n}\n\nconst vikeReactConfigImport = 'import:vike-react/config:default'\n\nconst nivelConfig = {\n meta: {\n docs: {\n env: {\n server: true,\n client: true,\n },\n global: true,\n },\n },\n prerender: true,\n trailingSlash: true,\n vite: viteConfig as Record<string, unknown>,\n} satisfies Config\n\nexport const createNivelVikeConfig = (docsConfig: DocsConfig) => {\n return {\n ...nivelConfig,\n title: docsConfig.siteTitle,\n description: docsConfig.siteDescription ?? `${docsConfig.siteTitle} documentation`,\n extends: [vikeReactConfigImport] as unknown as Config['extends'],\n htmlAttributes: {\n 'data-theme': getDefaultConsumerDataTheme(docsConfig),\n },\n
|
|
1
|
+
{"version":3,"sources":["../src/vike/index.ts","../src/mdx/plugins/rehypeDocsHeadings.ts"],"sourcesContent":["export { nivelConfig as default }\n\nimport mdx from '@mdx-js/rollup'\nimport remarkGfm from 'remark-gfm'\nimport type { Config } from 'vike/types'\nimport type { PluginOption, UserConfig } from 'vite'\nimport type { DocsConfig } from '../docs/types.js'\nimport { getCodeBlockMdxPlugins } from '../mdx/code-blocks/index.js'\nimport { rehypeDocsHeadings } from '../mdx/plugins/rehypeDocsHeadings.js'\nimport { nivelPagesPlugin } from '../runtime/node/index.js'\n\nprocess.env.VIKE_CRAWL ??= JSON.stringify({ git: false })\n\nconst codeBlockMdxPlugins = getCodeBlockMdxPlugins()\n\nconst viteConfig: UserConfig = {\n plugins: [\n {\n ...mdx({\n providerImportSource: '@unterberg/nivel/mdx',\n ...codeBlockMdxPlugins,\n rehypePlugins: [...codeBlockMdxPlugins.rehypePlugins, rehypeDocsHeadings],\n remarkPlugins: [remarkGfm, ...codeBlockMdxPlugins.remarkPlugins],\n }),\n enforce: 'pre',\n } as PluginOption,\n nivelPagesPlugin(),\n ],\n ssr: {\n noExternal: ['@unterberg/nivel'],\n },\n}\n\nconst getDefaultConsumerDataTheme = (docsConfig: DocsConfig) => {\n const defaultPreference = docsConfig.theme?.defaultPreference ?? 'light'\n const lightThemeName = docsConfig.theme?.light ?? 'consumer-light'\n const darkThemeName = docsConfig.theme?.dark ?? 'consumer-dark'\n\n return defaultPreference === 'dark' ? darkThemeName : lightThemeName\n}\n\nconst vikeReactConfigImport = 'import:vike-react/config:default'\n\nconst nivelConfig = {\n meta: {\n docs: {\n env: {\n server: true,\n client: true,\n },\n global: true,\n },\n },\n prerender: true,\n trailingSlash: true,\n vite: viteConfig as Record<string, unknown>,\n} satisfies Config\n\nexport const createNivelVikeConfig = (docsConfig: DocsConfig) => {\n return {\n ...nivelConfig,\n title: docsConfig.siteTitle,\n description: docsConfig.siteDescription ?? `${docsConfig.siteTitle} documentation`,\n extends: [vikeReactConfigImport] as unknown as Config['extends'],\n htmlAttributes: {\n 'data-theme': getDefaultConsumerDataTheme(docsConfig),\n },\n prerender: true,\n } as Config\n}\n","// attention: no HMR is active for this file, changes require a full engine pre-build -> dev / preview\nimport { visit } from 'unist-util-visit'\nimport type { ElementContentNode, ElementNode, HtmlRootNode } from '../ast.js'\nimport { createHeadingSlugger, normalizeHeadingTitle } from '../../docs/docHeadings.js'\n\nconst headingTags = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])\n\nconst getNodeText = (node: ElementContentNode | HtmlRootNode): string => {\n if (node.type === 'text') {\n return typeof node.value === 'string' ? node.value : ''\n }\n\n if ('children' in node) {\n return node.children.map((child) => getNodeText(child)).join('')\n }\n\n return ''\n}\n\nconst getClassNames = (value: unknown): string[] => {\n if (Array.isArray(value)) {\n return value.flatMap((entry) => getClassNames(entry))\n }\n\n if (typeof value === 'string') {\n return value.split(/\\s+/).filter(Boolean)\n }\n\n return []\n}\n\nconst createLinkIconLine = (x1: number, y1: number, x2: number, y2: number): ElementNode => {\n return {\n type: 'element',\n tagName: 'line',\n properties: { x1, y1, x2, y2 },\n children: [],\n }\n}\n\nexport const rehypeDocsHeadings = () => {\n return (tree: HtmlRootNode) => {\n const slugify = createHeadingSlugger()\n\n visit(tree, 'element', (node: ElementNode) => {\n if (!headingTags.has(node?.tagName)) {\n return\n }\n\n const title = normalizeHeadingTitle(getNodeText(node))\n if (!title) {\n return\n }\n\n node.properties ??= {}\n\n if (typeof node.properties.id !== 'string' || node.properties.id === '') {\n node.properties.id = slugify(title)\n }\n\n const classNames = getClassNames(node.properties.className)\n if (!classNames.includes('scroll-mt-24')) {\n node.properties.className = [\n ...classNames,\n 'scroll-mt-24',\n 'flex gap-2 items-center',\n 'group',\n 'relative',\n 'w-fit',\n ].join(' ')\n }\n\n // create link element with has and anchor icon\n const linkElement: ElementNode = {\n type: 'element',\n tagName: 'a',\n properties: {\n href: `#${node.properties.id}`,\n 'data-copy-heading-link': '',\n 'aria-hidden': 'true',\n 'aria-label': `Copy link to heading: ${title}`,\n title: `Copy link to heading: ${title}`,\n className: ['docs-heading-link absolute inset-0 flex items-center justify-end text-primary-muted'],\n },\n children: [\n {\n type: 'element',\n tagName: 'svg',\n properties: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: 16,\n height: 16,\n viewBox: '0 0 24 24',\n fill: 'none',\n stroke: 'currentColor',\n 'stroke-width': 2,\n 'stroke-linecap': 'round',\n 'stroke-linejoin': 'round',\n className: ['w-4 h-4 hidden group-hover:block translate-x-5'],\n },\n children: [\n createLinkIconLine(4, 9, 20, 9),\n createLinkIconLine(4, 15, 20, 15),\n createLinkIconLine(10, 3, 8, 21),\n createLinkIconLine(16, 3, 14, 21),\n ],\n },\n ],\n }\n node.children.push(linkElement)\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAEA,OAAO,SAAS;AAChB,OAAO,eAAe;;;ACFtB,SAAS,aAAa;AAItB,IAAM,cAAc,oBAAI,IAAI,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI,CAAC;AAEhE,IAAM,cAAc,CAAC,SAAoD;AACvE,MAAI,KAAK,SAAS,QAAQ;AACxB,WAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ;AAAA,EACvD;AAEA,MAAI,cAAc,MAAM;AACtB,WAAO,KAAK,SAAS,IAAI,CAAC,UAAU,YAAY,KAAK,CAAC,EAAE,KAAK,EAAE;AAAA,EACjE;AAEA,SAAO;AACT;AAEA,IAAM,gBAAgB,CAAC,UAA6B;AAClD,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,QAAQ,CAAC,UAAU,cAAc,KAAK,CAAC;AAAA,EACtD;AAEA,MAAI,OAAO,UA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MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,eAAe;AAAA,EACf,MAAM;AACR;AAEO,IAAM,wBAAwB,CAAC,eAA2B;AAC/D,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,WAAW;AAAA,IAClB,aAAa,WAAW,mBAAmB,GAAG,WAAW,SAAS;AAAA,IAClE,SAAS,CAAC,qBAAqB;AAAA,IAC/B,gBAAgB;AAAA,MACd,cAAc,4BAA4B,UAAU;AAAA,IACtD;AAAA,IACA,WAAW;AAAA,EACb;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unterberg/nivel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsup",
|
|
76
76
|
"dev": "tsup --watch",
|
|
77
|
-
"test": "
|
|
77
|
+
"test": "node --import tsx --test tests/*.test.mjs tests/*.test.ts",
|
|
78
78
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|