@graphql-markdown/formatters 1.0.2 → 1.1.0
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/defaults.d.ts +27 -0
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +34 -1
- package/dist/docfx/index.d.ts +3 -7
- package/dist/docfx/index.d.ts.map +1 -1
- package/dist/docfx/index.js +109 -40
- package/dist/docusaurus/index.d.ts +16 -0
- package/dist/docusaurus/index.d.ts.map +1 -1
- package/dist/docusaurus/index.js +34 -3
- package/dist/fumadocs/index.d.ts +9 -0
- package/dist/fumadocs/index.d.ts.map +1 -1
- package/dist/fumadocs/index.js +14 -1
- package/dist/honkit/index.d.ts +3 -1
- package/dist/honkit/index.d.ts.map +1 -1
- package/dist/honkit/index.js +5 -2
- package/dist/hugo/index.d.ts +1 -1
- package/dist/hugo/index.d.ts.map +1 -1
- package/dist/hugo/index.js +6 -4
- package/dist/mdbook/index.d.ts +1 -1
- package/dist/mdbook/index.d.ts.map +1 -1
- package/dist/mdbook/index.js +7 -9
- package/dist/mkdocs/index.d.ts +3 -2
- package/dist/mkdocs/index.d.ts.map +1 -1
- package/dist/mkdocs/index.js +6 -7
- package/dist/output.d.ts +58 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +112 -0
- package/dist/starlight/index.d.ts +13 -0
- package/dist/starlight/index.d.ts.map +1 -1
- package/dist/starlight/index.js +14 -1
- package/dist/version.d.ts +61 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +119 -0
- package/dist/vocs/index.d.ts +15 -0
- package/dist/vocs/index.d.ts.map +1 -1
- package/dist/vocs/index.js +16 -1
- package/package.json +1 -1
package/dist/mdbook/index.js
CHANGED
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.afterRenderFilesHook = exports.createMDXFormatter = exports.afterRenderTypeEntitiesHook = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.mdxExtension = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
|
|
13
|
+
exports.afterRenderFilesHook = exports.createMDXFormatter = exports.afterRenderTypeEntitiesHook = exports.formatMDXSpecifiedByLink = exports.formatMDXPermalink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.mdxExtension = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
|
|
14
14
|
const node_path_1 = require("node:path");
|
|
15
15
|
const helpers_1 = require("@graphql-markdown/helpers");
|
|
16
16
|
const utils_1 = require("@graphql-markdown/utils");
|
|
17
17
|
const defaults_1 = require("../defaults");
|
|
18
|
+
const output_1 = require("../output");
|
|
18
19
|
/**
|
|
19
20
|
* Formats a badge as Markdown bold text — mdBook has no badge component.
|
|
20
21
|
* @param badge - Badge data containing text
|
|
@@ -85,6 +86,7 @@ exports.formatMDXLink = formatMDXLink;
|
|
|
85
86
|
var defaults_2 = require("../defaults");
|
|
86
87
|
Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
|
|
87
88
|
Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
|
|
89
|
+
Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
|
|
88
90
|
Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
|
|
89
91
|
const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
|
|
90
92
|
return content.replaceAll(/\]\((\/[^)\s#]+)(#[^)\s]+)?\)/g, (_match, urlPath, hash = "") => {
|
|
@@ -110,12 +112,7 @@ const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
|
|
|
110
112
|
* work correctly regardless of where the book is hosted.
|
|
111
113
|
*/
|
|
112
114
|
const afterRenderTypeEntitiesHook = async (event) => {
|
|
113
|
-
|
|
114
|
-
const content = await (0, utils_1.readFile)(filePath, "utf-8");
|
|
115
|
-
const rewrittenContent = rewriteInternalLinks(content, filePath, outputDir, baseURL);
|
|
116
|
-
if (rewrittenContent !== content) {
|
|
117
|
-
await (0, utils_1.saveFile)(filePath, rewrittenContent);
|
|
118
|
-
}
|
|
115
|
+
await (0, output_1.rewriteRenderedPage)(event, rewriteInternalLinks);
|
|
119
116
|
};
|
|
120
117
|
exports.afterRenderTypeEntitiesHook = afterRenderTypeEntitiesHook;
|
|
121
118
|
/**
|
|
@@ -132,6 +129,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
132
129
|
formatMDXFrontmatter: exports.formatMDXFrontmatter,
|
|
133
130
|
formatMDXLink: exports.formatMDXLink,
|
|
134
131
|
formatMDXNameEntity: defaults_1.formatMDXNameEntity,
|
|
132
|
+
formatMDXPermalink: defaults_1.formatMDXPermalink,
|
|
135
133
|
formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
|
|
136
134
|
};
|
|
137
135
|
};
|
|
@@ -156,7 +154,7 @@ const SECTION_ORDER = [
|
|
|
156
154
|
* by top-level section (Operations / Types) and category, then writes the file.
|
|
157
155
|
*/
|
|
158
156
|
const afterRenderFilesHook = async (event) => {
|
|
159
|
-
const { baseURL, outputDir, rootDir, pages } = event.data;
|
|
157
|
+
const { baseURL, outputDir, rootDir, pages, outputAdapter } = event.data;
|
|
160
158
|
const summaryPath = (0, node_path_1.join)(rootDir, "SUMMARY.md");
|
|
161
159
|
const allPages = pages
|
|
162
160
|
.flat()
|
|
@@ -203,6 +201,6 @@ const afterRenderFilesHook = async (event) => {
|
|
|
203
201
|
}
|
|
204
202
|
lines.push("");
|
|
205
203
|
}
|
|
206
|
-
await (0,
|
|
204
|
+
await (0, output_1.writeOutput)(summaryPath, lines.join("\n"), outputAdapter);
|
|
207
205
|
};
|
|
208
206
|
exports.afterRenderFilesHook = afterRenderFilesHook;
|
package/dist/mkdocs/index.d.ts
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, RenderTypeEntitiesHook } from "@graphql-markdown/types";
|
|
10
|
-
import { formatMDXBullet, formatMDXLink } from "../defaults";
|
|
10
|
+
import { formatMDXBullet, formatMDXLink, formatMDXPermalink } from "../defaults";
|
|
11
11
|
export declare const __default: {
|
|
12
12
|
formatMDXBullet: typeof formatMDXBullet;
|
|
13
13
|
formatMDXLink: typeof formatMDXLink;
|
|
14
|
+
formatMDXPermalink: typeof formatMDXPermalink;
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* Formats a badge as an inline HTML mark element.
|
|
@@ -60,7 +61,7 @@ export declare const mdxExtension: ".md";
|
|
|
60
61
|
* @param event - Hook payload containing the current file path and renderer output context
|
|
61
62
|
*/
|
|
62
63
|
export declare const afterRenderTypeEntitiesHook: RenderTypeEntitiesHook;
|
|
63
|
-
export { formatMDXBullet } from "../defaults";
|
|
64
|
+
export { formatMDXBullet, formatMDXPermalink } from "../defaults";
|
|
64
65
|
/**
|
|
65
66
|
* Creates an MkDocs Material formatter.
|
|
66
67
|
* @param _meta - Unused metadata parameter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mkdocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mkdocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EACL,eAAe,EACf,aAAa,EACb,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAmCF;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SAEhD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAIF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAEtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAGF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,sBAIzC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC"}
|
package/dist/mkdocs/index.js
CHANGED
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.createMDXFormatter = exports.formatMDXBullet = exports.afterRenderTypeEntitiesHook = exports.mdxExtension = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.__default = void 0;
|
|
11
|
+
exports.createMDXFormatter = exports.formatMDXPermalink = exports.formatMDXBullet = exports.afterRenderTypeEntitiesHook = exports.mdxExtension = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.__default = void 0;
|
|
12
12
|
const helpers_1 = require("@graphql-markdown/helpers");
|
|
13
13
|
const utils_1 = require("@graphql-markdown/utils");
|
|
14
14
|
const defaults_1 = require("../defaults");
|
|
15
|
+
const output_1 = require("../output");
|
|
15
16
|
exports.__default = {
|
|
16
17
|
formatMDXBullet: defaults_1.formatMDXBullet,
|
|
17
18
|
formatMDXLink: defaults_1.formatMDXLink,
|
|
19
|
+
formatMDXPermalink: defaults_1.formatMDXPermalink,
|
|
18
20
|
};
|
|
19
21
|
const ADMONITION_TYPE_MAP = {
|
|
20
22
|
note: "note",
|
|
@@ -108,16 +110,12 @@ exports.mdxExtension = ".md";
|
|
|
108
110
|
* @param event - Hook payload containing the current file path and renderer output context
|
|
109
111
|
*/
|
|
110
112
|
const afterRenderTypeEntitiesHook = async (event) => {
|
|
111
|
-
|
|
112
|
-
const content = await (0, utils_1.readFile)(filePath, "utf-8");
|
|
113
|
-
const rewrittenContent = rewriteInternalLinks(content, filePath, outputDir, baseURL);
|
|
114
|
-
if (rewrittenContent !== content) {
|
|
115
|
-
await (0, utils_1.saveFile)(filePath, rewrittenContent);
|
|
116
|
-
}
|
|
113
|
+
await (0, output_1.rewriteRenderedPage)(event, rewriteInternalLinks);
|
|
117
114
|
};
|
|
118
115
|
exports.afterRenderTypeEntitiesHook = afterRenderTypeEntitiesHook;
|
|
119
116
|
var defaults_2 = require("../defaults");
|
|
120
117
|
Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
|
|
118
|
+
Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
|
|
121
119
|
/**
|
|
122
120
|
* Creates an MkDocs Material formatter.
|
|
123
121
|
* @param _meta - Unused metadata parameter
|
|
@@ -132,6 +130,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
132
130
|
formatMDXFrontmatter: exports.formatMDXFrontmatter,
|
|
133
131
|
formatMDXLink: defaults_1.formatMDXLink,
|
|
134
132
|
formatMDXNameEntity: exports.formatMDXNameEntity,
|
|
133
|
+
formatMDXPermalink: defaults_1.formatMDXPermalink,
|
|
135
134
|
formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
|
|
136
135
|
};
|
|
137
136
|
};
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output helpers for formatter lifecycle hooks.
|
|
3
|
+
*
|
|
4
|
+
* Hooks post-process pages the renderer has already written, so they must go
|
|
5
|
+
* through the same destination the renderer used. Reaching for the filesystem
|
|
6
|
+
* directly works only as long as the default adapter is in play, and silently
|
|
7
|
+
* misses every page when the output is redirected elsewhere.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { Maybe, OutputAdapter } from "@graphql-markdown/types";
|
|
12
|
+
/**
|
|
13
|
+
* Reads back a page the renderer has written, through its output destination.
|
|
14
|
+
*
|
|
15
|
+
* The page was just written, so nothing coming back means the destination
|
|
16
|
+
* cannot be read - a write-only adapter, a stubbed `readFile`, or a store that
|
|
17
|
+
* is not read-your-writes consistent. Post-processing cannot run without it,
|
|
18
|
+
* which is reported rather than silently skipped.
|
|
19
|
+
*
|
|
20
|
+
* @param filePath - Path of the generated page
|
|
21
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
22
|
+
* @returns The page content, or `undefined` if it cannot be read back
|
|
23
|
+
* @throws An error the first time this adapter cannot read a page back, so the
|
|
24
|
+
* skipped post-processing surfaces once instead of once per page.
|
|
25
|
+
*/
|
|
26
|
+
export declare const readOutput: (filePath: string, outputAdapter: Maybe<OutputAdapter>) => Promise<string | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Reads a file the formatter maintains itself, where absence is expected.
|
|
29
|
+
*
|
|
30
|
+
* Unlike {@link readOutput} this reports nothing when there is no content: a
|
|
31
|
+
* navigation or metadata file legitimately does not exist until the formatter
|
|
32
|
+
* creates it on the first page of a directory.
|
|
33
|
+
*
|
|
34
|
+
* @param filePath - Path of the file to read
|
|
35
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
36
|
+
* @returns The file content, or `undefined` when there is none
|
|
37
|
+
*/
|
|
38
|
+
export declare const readOptionalOutput: (filePath: string, outputAdapter: Maybe<OutputAdapter>) => Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Writes a file through the output destination, creating its directory first.
|
|
41
|
+
*
|
|
42
|
+
* @param filePath - Path of the file to write
|
|
43
|
+
* @param content - File content
|
|
44
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
45
|
+
*/
|
|
46
|
+
export declare const writeOutput: (filePath: string, content: string, outputAdapter: Maybe<OutputAdapter>, dirPath?: string) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Rewrites the content of a page a formatter has just rendered.
|
|
49
|
+
*
|
|
50
|
+
* The read-modify-write around an `afterRenderTypeEntities` hook is identical
|
|
51
|
+
* for every preset that post-processes its own output; only the rewriting
|
|
52
|
+
* differs. Presets supply that and nothing else.
|
|
53
|
+
*
|
|
54
|
+
* @param event - The hook event, carrying the page path and its destination
|
|
55
|
+
* @param rewrite - Returns the new content, or the content unchanged to skip
|
|
56
|
+
*/
|
|
57
|
+
export declare const rewriteRenderedPage: (event: unknown, rewrite: (content: string, filePath: string, outputDir: string, baseURL: string) => string) => Promise<void>;
|
|
58
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA0BpE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,aACX,MAAM,iBACD,KAAK,CAAC,aAAa,CAAC,KAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAgB5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,aACnB,MAAM,iBACD,KAAK,CAAC,aAAa,CAAC,KAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAE5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,MAAM,WACP,MAAM,iBACA,KAAK,CAAC,aAAa,CAAC,YACzB,MAAM,KACf,OAAO,CAAC,IAAI,CAQd,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,UACvB,OAAO,WACL,CACP,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,KACZ,MAAM,KACV,OAAO,CAAC,IAAI,CAuBd,CAAC"}
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Output helpers for formatter lifecycle hooks.
|
|
4
|
+
*
|
|
5
|
+
* Hooks post-process pages the renderer has already written, so they must go
|
|
6
|
+
* through the same destination the renderer used. Reaching for the filesystem
|
|
7
|
+
* directly works only as long as the default adapter is in play, and silently
|
|
8
|
+
* misses every page when the output is redirected elsewhere.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.rewriteRenderedPage = exports.writeOutput = exports.readOptionalOutput = exports.readOutput = void 0;
|
|
14
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the destination a hook must use, falling back to the filesystem.
|
|
17
|
+
*
|
|
18
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
19
|
+
* @returns The adapter to read from and write to
|
|
20
|
+
*/
|
|
21
|
+
const getOutputAdapter = (outputAdapter) => {
|
|
22
|
+
return outputAdapter ?? utils_1.fsOutputAdapter;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Adapters a failed read-back has already been reported for.
|
|
26
|
+
*
|
|
27
|
+
* A destination that cannot read back its own writes fails on every page, so
|
|
28
|
+
* reporting each one would bury the run in identical errors. Keyed by adapter
|
|
29
|
+
* rather than a flag, so one destination going quiet says nothing about
|
|
30
|
+
* another. An adapter instance reused across several runs in one process is
|
|
31
|
+
* therefore reported on its first failing run only.
|
|
32
|
+
*/
|
|
33
|
+
const readBackReported = new WeakSet();
|
|
34
|
+
/**
|
|
35
|
+
* Reads back a page the renderer has written, through its output destination.
|
|
36
|
+
*
|
|
37
|
+
* The page was just written, so nothing coming back means the destination
|
|
38
|
+
* cannot be read - a write-only adapter, a stubbed `readFile`, or a store that
|
|
39
|
+
* is not read-your-writes consistent. Post-processing cannot run without it,
|
|
40
|
+
* which is reported rather than silently skipped.
|
|
41
|
+
*
|
|
42
|
+
* @param filePath - Path of the generated page
|
|
43
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
44
|
+
* @returns The page content, or `undefined` if it cannot be read back
|
|
45
|
+
* @throws An error the first time this adapter cannot read a page back, so the
|
|
46
|
+
* skipped post-processing surfaces once instead of once per page.
|
|
47
|
+
*/
|
|
48
|
+
const readOutput = async (filePath, outputAdapter) => {
|
|
49
|
+
const adapter = getOutputAdapter(outputAdapter);
|
|
50
|
+
const content = await adapter.readFile(filePath);
|
|
51
|
+
if (typeof content === "string") {
|
|
52
|
+
return content;
|
|
53
|
+
}
|
|
54
|
+
if (!readBackReported.has(adapter)) {
|
|
55
|
+
readBackReported.add(adapter);
|
|
56
|
+
throw new Error(`Cannot read back "${filePath}" from the output destination: the formatter cannot post-process what it wrote (e.g. internal link rewriting, navigation/metadata updates) for this run.`);
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
};
|
|
60
|
+
exports.readOutput = readOutput;
|
|
61
|
+
/**
|
|
62
|
+
* Reads a file the formatter maintains itself, where absence is expected.
|
|
63
|
+
*
|
|
64
|
+
* Unlike {@link readOutput} this reports nothing when there is no content: a
|
|
65
|
+
* navigation or metadata file legitimately does not exist until the formatter
|
|
66
|
+
* creates it on the first page of a directory.
|
|
67
|
+
*
|
|
68
|
+
* @param filePath - Path of the file to read
|
|
69
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
70
|
+
* @returns The file content, or `undefined` when there is none
|
|
71
|
+
*/
|
|
72
|
+
const readOptionalOutput = async (filePath, outputAdapter) => {
|
|
73
|
+
return getOutputAdapter(outputAdapter).readFile(filePath);
|
|
74
|
+
};
|
|
75
|
+
exports.readOptionalOutput = readOptionalOutput;
|
|
76
|
+
/**
|
|
77
|
+
* Writes a file through the output destination, creating its directory first.
|
|
78
|
+
*
|
|
79
|
+
* @param filePath - Path of the file to write
|
|
80
|
+
* @param content - File content
|
|
81
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
82
|
+
*/
|
|
83
|
+
const writeOutput = async (filePath, content, outputAdapter, dirPath) => {
|
|
84
|
+
const adapter = getOutputAdapter(outputAdapter);
|
|
85
|
+
if (typeof dirPath === "string") {
|
|
86
|
+
await adapter.ensureDir?.(dirPath);
|
|
87
|
+
}
|
|
88
|
+
await adapter.writeFile(filePath, content);
|
|
89
|
+
};
|
|
90
|
+
exports.writeOutput = writeOutput;
|
|
91
|
+
/**
|
|
92
|
+
* Rewrites the content of a page a formatter has just rendered.
|
|
93
|
+
*
|
|
94
|
+
* The read-modify-write around an `afterRenderTypeEntities` hook is identical
|
|
95
|
+
* for every preset that post-processes its own output; only the rewriting
|
|
96
|
+
* differs. Presets supply that and nothing else.
|
|
97
|
+
*
|
|
98
|
+
* @param event - The hook event, carrying the page path and its destination
|
|
99
|
+
* @param rewrite - Returns the new content, or the content unchanged to skip
|
|
100
|
+
*/
|
|
101
|
+
const rewriteRenderedPage = async (event, rewrite) => {
|
|
102
|
+
const { baseURL, filePath, outputAdapter, outputDir } = event.data;
|
|
103
|
+
const content = await (0, exports.readOutput)(filePath, outputAdapter);
|
|
104
|
+
if (typeof content !== "string") {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const rewritten = rewrite(content, filePath, outputDir, baseURL);
|
|
108
|
+
if (rewritten !== content) {
|
|
109
|
+
await (0, exports.writeOutput)(filePath, rewritten, outputAdapter);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
exports.rewriteRenderedPage = rewriteRenderedPage;
|
|
@@ -8,6 +8,19 @@
|
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
10
|
import type { AdmonitionType, Badge, Formatter, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
|
|
11
|
+
import { formatMDXEscapedPermalink } from "../defaults";
|
|
12
|
+
/**
|
|
13
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
14
|
+
* escaped to remain valid MDX.
|
|
15
|
+
*
|
|
16
|
+
* Starlight has no built-in custom header id syntax, so the permalink is inert
|
|
17
|
+
* unless a remark plugin such as `remark-custom-heading-id` is configured. Turn
|
|
18
|
+
* it off with `docOptions.sectionHeaderId: false`.
|
|
19
|
+
*
|
|
20
|
+
* @param id - The ID of the section header
|
|
21
|
+
* @returns Formatted permalink string
|
|
22
|
+
*/
|
|
23
|
+
export declare const formatMDXPermalink: typeof formatMDXEscapedPermalink;
|
|
11
24
|
/** File extension used for generated pages. */
|
|
12
25
|
export declare const mdxExtension: ".mdx";
|
|
13
26
|
/** MDX import statement prepended to every generated file to register Starlight components. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/starlight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/starlight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAIL,yBAAyB,EAG1B,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,kCAA4B,CAAC;AAE5D,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C,+FAA+F;AAC/F,eAAO,MAAM,cAAc,EAAE,SAEf,CAAC;AAEf;;;;;GAKG;AACH,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAG3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAGF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAE9C,CAAC;AAEF,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC"}
|
package/dist/starlight/index.js
CHANGED
|
@@ -9,9 +9,21 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = exports.mdxExtension = void 0;
|
|
12
|
+
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = exports.mdxExtension = exports.formatMDXPermalink = void 0;
|
|
13
13
|
const utils_1 = require("@graphql-markdown/utils");
|
|
14
14
|
const defaults_1 = require("../defaults");
|
|
15
|
+
/**
|
|
16
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
17
|
+
* escaped to remain valid MDX.
|
|
18
|
+
*
|
|
19
|
+
* Starlight has no built-in custom header id syntax, so the permalink is inert
|
|
20
|
+
* unless a remark plugin such as `remark-custom-heading-id` is configured. Turn
|
|
21
|
+
* it off with `docOptions.sectionHeaderId: false`.
|
|
22
|
+
*
|
|
23
|
+
* @param id - The ID of the section header
|
|
24
|
+
* @returns Formatted permalink string
|
|
25
|
+
*/
|
|
26
|
+
exports.formatMDXPermalink = defaults_1.formatMDXEscapedPermalink;
|
|
15
27
|
/** File extension used for generated pages. */
|
|
16
28
|
exports.mdxExtension = ".mdx";
|
|
17
29
|
/** MDX import statement prepended to every generated file to register Starlight components. */
|
|
@@ -71,6 +83,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
71
83
|
formatMDXFrontmatter: defaults_1.formatMDXFrontmatter,
|
|
72
84
|
formatMDXLink: exports.formatMDXLink,
|
|
73
85
|
formatMDXNameEntity: defaults_1.formatMDXNameEntity,
|
|
86
|
+
formatMDXPermalink: exports.formatMDXPermalink,
|
|
74
87
|
formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
|
|
75
88
|
};
|
|
76
89
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for gating formatter output on the target framework version.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { Maybe, MetaInfo } from "@graphql-markdown/types";
|
|
7
|
+
/** A framework version, narrowed down to the parts used for comparison. */
|
|
8
|
+
export interface FrameworkVersion {
|
|
9
|
+
major: number;
|
|
10
|
+
minor?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
14
|
+
* that its version matches `version`.
|
|
15
|
+
*
|
|
16
|
+
* Only the parts carried by `version` are compared, so `{ major: 2 }` matches
|
|
17
|
+
* any `2.x` release. An unknown, unparsable or mismatched framework version
|
|
18
|
+
* returns `false`.
|
|
19
|
+
*
|
|
20
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
21
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
22
|
+
* @param version - The version to match
|
|
23
|
+
* @returns `true` if the framework and its version match
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* const meta = {
|
|
28
|
+
* generatorFrameworkName: "docusaurus",
|
|
29
|
+
* generatorFrameworkVersion: "2.4.3",
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 2 }); // true
|
|
33
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 3 }); // false
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const isFrameworkVersion: (meta: Maybe<MetaInfo>, framework: string, version: FrameworkVersion) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
39
|
+
* that its version is `minVersion` or above.
|
|
40
|
+
*
|
|
41
|
+
* An unknown, unparsable or mismatched framework version returns `false`, so
|
|
42
|
+
* callers fall back to the output supported by every version.
|
|
43
|
+
*
|
|
44
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
45
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
46
|
+
* @param minVersion - The minimum version required by the caller
|
|
47
|
+
* @returns `true` if the framework matches and its version is high enough
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```js
|
|
51
|
+
* const meta = {
|
|
52
|
+
* generatorFrameworkName: "docusaurus",
|
|
53
|
+
* generatorFrameworkVersion: "3.10.2",
|
|
54
|
+
* };
|
|
55
|
+
*
|
|
56
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 3, minor: 10 }); // true
|
|
57
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 4 }); // false
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const isFrameworkVersionAtLeast: (meta: Maybe<MetaInfo>, framework: string, minVersion: FrameworkVersion) => boolean;
|
|
61
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAE/D,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAwED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kBAAkB,SACvB,KAAK,CAAC,QAAQ,CAAC,aACV,MAAM,WACR,gBAAgB,KACxB,OAEF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,SAC9B,KAAK,CAAC,QAAQ,CAAC,aACV,MAAM,cACL,gBAAgB,KAC3B,OAIF,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Helpers for gating formatter output on the target framework version.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isFrameworkVersionAtLeast = exports.isFrameworkVersion = void 0;
|
|
9
|
+
const VERSION_EXPRESSION = /^\D*(?<major>\d+)(?:\.(?<minor>\d+))?/;
|
|
10
|
+
/**
|
|
11
|
+
* Parses the leading `major[.minor]` of a version string.
|
|
12
|
+
*
|
|
13
|
+
* Any prefix (`v`, `^`, `~`) is ignored, as is anything trailing the minor
|
|
14
|
+
* (patch, prerelease, build metadata).
|
|
15
|
+
*
|
|
16
|
+
* @param version - The version string to parse, eg `"3.10.2"`
|
|
17
|
+
* @returns The parsed version, or `undefined` if the string carries no version
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* parseFrameworkVersion("3.10.2"); // { major: 3, minor: 10 }
|
|
22
|
+
* parseFrameworkVersion("next"); // undefined
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const parseFrameworkVersion = (version) => {
|
|
26
|
+
const parsed = VERSION_EXPRESSION.exec(version ?? "");
|
|
27
|
+
if (!parsed?.groups) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
// an optional group is typed as always present, but is undefined when absent
|
|
31
|
+
return {
|
|
32
|
+
major: Number(parsed.groups.major),
|
|
33
|
+
minor: Number(parsed.groups.minor || 0),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Compares the generator framework version declared in `meta` with `version`.
|
|
38
|
+
*
|
|
39
|
+
* Only the parts carried by `version` are compared, so `{ major: 2 }` matches
|
|
40
|
+
* any `2.x` release.
|
|
41
|
+
*
|
|
42
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
43
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
44
|
+
* @param version - The version to compare against
|
|
45
|
+
* @returns A negative number if the framework version is lower, `0` if it
|
|
46
|
+
* matches, a positive number if it is higher, or `undefined` if the framework
|
|
47
|
+
* does not match or carries no parsable version
|
|
48
|
+
*/
|
|
49
|
+
const compareFrameworkVersion = (meta, framework, version) => {
|
|
50
|
+
if (meta?.generatorFrameworkName !== framework) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const parsed = parseFrameworkVersion(meta.generatorFrameworkVersion);
|
|
54
|
+
if (!parsed) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (parsed.major !== version.major) {
|
|
58
|
+
return parsed.major - version.major;
|
|
59
|
+
}
|
|
60
|
+
return typeof version.minor === "number"
|
|
61
|
+
? (parsed.minor ?? 0) - version.minor
|
|
62
|
+
: 0;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
66
|
+
* that its version matches `version`.
|
|
67
|
+
*
|
|
68
|
+
* Only the parts carried by `version` are compared, so `{ major: 2 }` matches
|
|
69
|
+
* any `2.x` release. An unknown, unparsable or mismatched framework version
|
|
70
|
+
* returns `false`.
|
|
71
|
+
*
|
|
72
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
73
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
74
|
+
* @param version - The version to match
|
|
75
|
+
* @returns `true` if the framework and its version match
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```js
|
|
79
|
+
* const meta = {
|
|
80
|
+
* generatorFrameworkName: "docusaurus",
|
|
81
|
+
* generatorFrameworkVersion: "2.4.3",
|
|
82
|
+
* };
|
|
83
|
+
*
|
|
84
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 2 }); // true
|
|
85
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 3 }); // false
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
const isFrameworkVersion = (meta, framework, version) => {
|
|
89
|
+
return compareFrameworkVersion(meta, framework, version) === 0;
|
|
90
|
+
};
|
|
91
|
+
exports.isFrameworkVersion = isFrameworkVersion;
|
|
92
|
+
/**
|
|
93
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
94
|
+
* that its version is `minVersion` or above.
|
|
95
|
+
*
|
|
96
|
+
* An unknown, unparsable or mismatched framework version returns `false`, so
|
|
97
|
+
* callers fall back to the output supported by every version.
|
|
98
|
+
*
|
|
99
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
100
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
101
|
+
* @param minVersion - The minimum version required by the caller
|
|
102
|
+
* @returns `true` if the framework matches and its version is high enough
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```js
|
|
106
|
+
* const meta = {
|
|
107
|
+
* generatorFrameworkName: "docusaurus",
|
|
108
|
+
* generatorFrameworkVersion: "3.10.2",
|
|
109
|
+
* };
|
|
110
|
+
*
|
|
111
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 3, minor: 10 }); // true
|
|
112
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 4 }); // false
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
const isFrameworkVersionAtLeast = (meta, framework, minVersion) => {
|
|
116
|
+
const compared = compareFrameworkVersion(meta, framework, minVersion);
|
|
117
|
+
return typeof compared === "number" && compared >= 0;
|
|
118
|
+
};
|
|
119
|
+
exports.isFrameworkVersionAtLeast = isFrameworkVersionAtLeast;
|
package/dist/vocs/index.d.ts
CHANGED
|
@@ -6,6 +6,21 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
import type { AdmonitionType, Badge, Formatter, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
|
|
9
|
+
import { formatMDXEscapedPermalink } from "../defaults";
|
|
10
|
+
/**
|
|
11
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
12
|
+
* escaped to remain valid MDX.
|
|
13
|
+
*
|
|
14
|
+
* Vocs has no custom header id syntax, so the permalink is inert unless a
|
|
15
|
+
* remark plugin is configured. Turn it off with
|
|
16
|
+
* `docOptions.sectionHeaderId: false`.
|
|
17
|
+
*
|
|
18
|
+
* @see https://vocs.dev/docs/markdown
|
|
19
|
+
*
|
|
20
|
+
* @param id - The ID of the section header
|
|
21
|
+
* @returns Formatted permalink string
|
|
22
|
+
*/
|
|
23
|
+
export declare const formatMDXPermalink: typeof formatMDXEscapedPermalink;
|
|
9
24
|
/** MDX import statement and inline component definitions prepended to every generated file. */
|
|
10
25
|
export declare const mdxDeclaration: MDXString;
|
|
11
26
|
/** File extension used for generated pages. */
|
package/dist/vocs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAEL,yBAAyB,EAG1B,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,kCAA4B,CAAC;AAE5D,+FAA+F;AAC/F,eAAO,MAAM,cAAc,EAAE,SAEf,CAAC;AAEf,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAG3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,qBAAgB,SAE3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAKvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAKF,CAAC;AAEF,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC"}
|
package/dist/vocs/index.js
CHANGED
|
@@ -7,10 +7,24 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxExtension = exports.mdxDeclaration = void 0;
|
|
10
|
+
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxExtension = exports.mdxDeclaration = exports.formatMDXPermalink = void 0;
|
|
11
11
|
const helpers_1 = require("@graphql-markdown/helpers");
|
|
12
12
|
const utils_1 = require("@graphql-markdown/utils");
|
|
13
13
|
const defaults_1 = require("../defaults");
|
|
14
|
+
/**
|
|
15
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
16
|
+
* escaped to remain valid MDX.
|
|
17
|
+
*
|
|
18
|
+
* Vocs has no custom header id syntax, so the permalink is inert unless a
|
|
19
|
+
* remark plugin is configured. Turn it off with
|
|
20
|
+
* `docOptions.sectionHeaderId: false`.
|
|
21
|
+
*
|
|
22
|
+
* @see https://vocs.dev/docs/markdown
|
|
23
|
+
*
|
|
24
|
+
* @param id - The ID of the section header
|
|
25
|
+
* @returns Formatted permalink string
|
|
26
|
+
*/
|
|
27
|
+
exports.formatMDXPermalink = defaults_1.formatMDXEscapedPermalink;
|
|
14
28
|
/** MDX import statement and inline component definitions prepended to every generated file. */
|
|
15
29
|
exports.mdxDeclaration = `
|
|
16
30
|
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em' }}> ● </span></>
|
|
@@ -92,6 +106,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
92
106
|
formatMDXFrontmatter: defaults_1.formatMDXFrontmatter,
|
|
93
107
|
formatMDXLink: exports.formatMDXLink,
|
|
94
108
|
formatMDXNameEntity: exports.formatMDXNameEntity,
|
|
109
|
+
formatMDXPermalink: exports.formatMDXPermalink,
|
|
95
110
|
formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
|
|
96
111
|
};
|
|
97
112
|
};
|