@graphql-markdown/formatters 1.0.0 → 1.0.2
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/docfx/index.d.ts.map +1 -1
- package/dist/docfx/index.js +58 -2
- package/dist/fumadocs/index.d.ts +4 -3
- package/dist/fumadocs/index.d.ts.map +1 -1
- package/dist/fumadocs/index.js +5 -8
- package/dist/honkit/index.d.ts +2 -1
- package/dist/honkit/index.d.ts.map +1 -1
- package/dist/mdbook/index.d.ts +12 -1
- package/dist/mdbook/index.d.ts.map +1 -1
- package/dist/mdbook/index.js +34 -2
- package/dist/mkdocs/index.d.ts +3 -2
- package/dist/mkdocs/index.d.ts.map +1 -1
- package/dist/starlight/index.d.ts +4 -25
- package/dist/starlight/index.d.ts.map +1 -1
- package/dist/starlight/index.js +6 -42
- package/dist/vocs/index.d.ts +3 -4
- package/dist/vocs/index.d.ts.map +1 -1
- package/dist/vocs/index.js +5 -8
- package/package.json +192 -192
- package/dist/docfx.d.ts +0 -20
- package/dist/docfx.d.ts.map +0 -1
- package/dist/docfx.js +0 -71
- package/dist/docusaurus.d.ts +0 -20
- package/dist/docusaurus.d.ts.map +0 -1
- package/dist/docusaurus.js +0 -72
- package/dist/hugo.d.ts +0 -20
- package/dist/hugo.d.ts.map +0 -1
- package/dist/hugo.js +0 -68
- package/dist/mdbook.d.ts +0 -20
- package/dist/mdbook.d.ts.map +0 -1
- package/dist/mdbook.js +0 -51
- package/dist/mkdocs.d.ts +0 -19
- package/dist/mkdocs.d.ts.map +0 -1
- package/dist/mkdocs.js +0 -65
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docfx/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACT,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docfx/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACT,MAAM,yBAAyB,CAAC;AA+BjC,sFAAsF;AACtF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIlD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAI3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAIF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,UACxB,KAAK,CAAC,kBAAkB,CAAC,aACrB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAgBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAE9C,CAAC;AAEF,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAW5D,CAAC;AAEF,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAgI3C;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAAE,sBA4DzC,CAAC"}
|
package/dist/docfx/index.js
CHANGED
|
@@ -110,6 +110,61 @@ const createMDXFormatter = (_meta) => {
|
|
|
110
110
|
};
|
|
111
111
|
exports.createMDXFormatter = createMDXFormatter;
|
|
112
112
|
exports.mdxExtension = ".md";
|
|
113
|
+
const isAbsoluteInternalLink = (content, urlStart) => {
|
|
114
|
+
if (content[urlStart] !== "/")
|
|
115
|
+
return null;
|
|
116
|
+
const closePos = content.indexOf(")", urlStart);
|
|
117
|
+
if (closePos === -1)
|
|
118
|
+
return null;
|
|
119
|
+
const urlWithHash = content.slice(urlStart, closePos);
|
|
120
|
+
if (/\s/u.test(urlWithHash))
|
|
121
|
+
return null;
|
|
122
|
+
return { closePos, urlWithHash };
|
|
123
|
+
};
|
|
124
|
+
const resolveLink = (urlWithHash, filePath, outputDir, normalizedBaseURL, baseSegment) => {
|
|
125
|
+
const sepIdx = urlWithHash.indexOf("#");
|
|
126
|
+
const [urlPath, hash] = sepIdx < 0
|
|
127
|
+
? [urlWithHash, ""]
|
|
128
|
+
: [urlWithHash.slice(0, sepIdx), urlWithHash.slice(sepIdx)];
|
|
129
|
+
// Strip any linkRoot prefix so toRelativeGeneratedDocLink can resolve the path.
|
|
130
|
+
// e.g. /docs/graphql/types/scalars/id → /graphql/types/scalars/id
|
|
131
|
+
const baseIndex = urlPath.indexOf(baseSegment);
|
|
132
|
+
if (baseIndex === -1)
|
|
133
|
+
return `](${urlWithHash})`;
|
|
134
|
+
const relative = (0, utils_1.toRelativeGeneratedDocLink)({
|
|
135
|
+
baseURL: normalizedBaseURL,
|
|
136
|
+
currentFilePath: filePath,
|
|
137
|
+
extension: exports.mdxExtension,
|
|
138
|
+
outputDir,
|
|
139
|
+
targetUrlPath: urlPath.slice(baseIndex),
|
|
140
|
+
});
|
|
141
|
+
return `](${relative ?? urlPath}${hash})`;
|
|
142
|
+
};
|
|
143
|
+
const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
|
|
144
|
+
const normalizedBaseURL = baseURL.split("/").filter(Boolean).join("/");
|
|
145
|
+
const baseSegment = `/${normalizedBaseURL}/`;
|
|
146
|
+
// Use indexOf scanning instead of regex to avoid ReDoS on file content.
|
|
147
|
+
const out = [];
|
|
148
|
+
let pos = 0;
|
|
149
|
+
while (pos < content.length) {
|
|
150
|
+
const markerPos = content.indexOf("](", pos);
|
|
151
|
+
if (markerPos === -1) {
|
|
152
|
+
out.push(content.slice(pos));
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
const urlStart = markerPos + 2;
|
|
156
|
+
const match = isAbsoluteInternalLink(content, urlStart);
|
|
157
|
+
if (!match) {
|
|
158
|
+
out.push(content.slice(pos, urlStart));
|
|
159
|
+
pos = urlStart;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
out.push(content.slice(pos, markerPos));
|
|
163
|
+
out.push(resolveLink(match.urlWithHash, filePath, outputDir, normalizedBaseURL, baseSegment));
|
|
164
|
+
pos = match.closePos + 1;
|
|
165
|
+
}
|
|
166
|
+
return out.join("");
|
|
167
|
+
};
|
|
113
168
|
// ─── toc.yml builder ────────────────────────────────────────────────────────
|
|
114
169
|
const writeQueue = new Map();
|
|
115
170
|
const queueFileUpdate = async (filePath, update) => {
|
|
@@ -143,7 +198,7 @@ const seenDirectories = new Set();
|
|
|
143
198
|
* are prepended as an "Overview" entry on first encounter.
|
|
144
199
|
*/
|
|
145
200
|
const afterRenderTypeEntitiesHook = async (event) => {
|
|
146
|
-
const { filePath, name, outputDir } = event.data;
|
|
201
|
+
const { baseURL, filePath, name, outputDir } = event.data;
|
|
147
202
|
const graphqlRoot = (0, node_path_1.resolve)(outputDir);
|
|
148
203
|
// Rewrite uid as a path-derived value to guarantee uniqueness across the site.
|
|
149
204
|
// e.g. operations/queries/continent.md → uid: operations-queries-continent
|
|
@@ -151,7 +206,8 @@ const afterRenderTypeEntitiesHook = async (event) => {
|
|
|
151
206
|
.replace(/\.mdx?$/, "")
|
|
152
207
|
.replaceAll(/[/\\]/g, "-");
|
|
153
208
|
const content = await (0, utils_1.readFile)(filePath, "utf-8");
|
|
154
|
-
const
|
|
209
|
+
const withUid = content.replace(/^(\s*)uid:.*$/m, `$1uid: ${uid}`);
|
|
210
|
+
const rewritten = rewriteInternalLinks(withUid, filePath, outputDir, baseURL);
|
|
155
211
|
if (rewritten !== content) {
|
|
156
212
|
await (0, utils_1.saveFile)(filePath, rewritten);
|
|
157
213
|
}
|
package/dist/fumadocs/index.d.ts
CHANGED
|
@@ -27,11 +27,12 @@ export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
|
|
|
27
27
|
*/
|
|
28
28
|
export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, _meta: Maybe<MetaInfo>) => MDXString;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Returns the link unchanged — Fumadocs routes `page.mdx` to `page` so
|
|
31
|
+
* links must not include the `.mdx` extension.
|
|
31
32
|
* @param link - Link data with URL and text
|
|
32
|
-
* @returns
|
|
33
|
+
* @returns Unmodified link
|
|
33
34
|
*/
|
|
34
|
-
export declare const formatMDXLink: (
|
|
35
|
+
export declare const formatMDXLink: (link: TypeLink) => TypeLink;
|
|
35
36
|
export { formatMDXBullet, formatMDXDetails, formatMDXFrontmatter, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
|
|
36
37
|
/**
|
|
37
38
|
* Creates a Fumadocs formatter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fumadocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;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/fumadocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAUjC,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C,sGAAsG;AACtG,eAAO,MAAM,cAAc,EAAE,SAGf,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,SAW5D,CAAC"}
|
package/dist/fumadocs/index.js
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
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
|
-
const helpers_1 = require("@graphql-markdown/helpers");
|
|
13
12
|
const utils_1 = require("@graphql-markdown/utils");
|
|
14
13
|
const defaults_1 = require("../defaults");
|
|
15
14
|
/** File extension used for generated pages. */
|
|
@@ -43,15 +42,13 @@ const formatMDXAdmonition = ({ text, title, type }, _meta) => {
|
|
|
43
42
|
};
|
|
44
43
|
exports.formatMDXAdmonition = formatMDXAdmonition;
|
|
45
44
|
/**
|
|
46
|
-
*
|
|
45
|
+
* Returns the link unchanged — Fumadocs routes `page.mdx` to `page` so
|
|
46
|
+
* links must not include the `.mdx` extension.
|
|
47
47
|
* @param link - Link data with URL and text
|
|
48
|
-
* @returns
|
|
48
|
+
* @returns Unmodified link
|
|
49
49
|
*/
|
|
50
|
-
const formatMDXLink = (
|
|
51
|
-
return
|
|
52
|
-
text,
|
|
53
|
-
url: (0, helpers_1.appendLinkExtension)(url, exports.mdxExtension),
|
|
54
|
-
};
|
|
50
|
+
const formatMDXLink = (link) => {
|
|
51
|
+
return link;
|
|
55
52
|
};
|
|
56
53
|
exports.formatMDXLink = formatMDXLink;
|
|
57
54
|
var defaults_2 = require("../defaults");
|
package/dist/honkit/index.d.ts
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
|
|
10
|
+
import { formatMDXBullet } from "../defaults";
|
|
10
11
|
export declare const __default: {
|
|
11
|
-
formatMDXBullet:
|
|
12
|
+
formatMDXBullet: typeof formatMDXBullet;
|
|
12
13
|
};
|
|
13
14
|
/** File extension used for generated pages — HonKit renders plain Markdown to HTML. */
|
|
14
15
|
export declare const mdxExtension: ".md";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/honkit/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,QAAQ,EACT,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/honkit/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,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,SAAS;;CAAsB,CAAC;AAE7C,uFAAuF;AACvF,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAS3C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SAKhD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAEtB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,UACxB,KAAK,CAAC,kBAAkB,CAAC,aACrB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAoBvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAEF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAW5D,CAAC"}
|
package/dist/mdbook/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
|
-
import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, RenderFilesHook, TypeLink } from "@graphql-markdown/types";
|
|
11
|
+
import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, RenderFilesHook, RenderTypeEntitiesHook, TypeLink } from "@graphql-markdown/types";
|
|
12
12
|
/**
|
|
13
13
|
* Formats a badge as Markdown bold text — mdBook has no badge component.
|
|
14
14
|
* @param badge - Badge data containing text
|
|
@@ -52,6 +52,17 @@ export declare const mdxExtension = ".md";
|
|
|
52
52
|
*/
|
|
53
53
|
export declare const formatMDXLink: (link: TypeLink) => TypeLink;
|
|
54
54
|
export { formatMDXBullet, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
|
|
55
|
+
/**
|
|
56
|
+
* Rewrites absolute generated doc links to page-relative `.md` paths after each page is rendered.
|
|
57
|
+
*
|
|
58
|
+
* mdBook resolves links relative to the book source root, so absolute paths
|
|
59
|
+
* like `/graphql/types/scalars/id.md` are rendered as `/graphql/types/scalars/id.html`
|
|
60
|
+
* in the output HTML — which breaks when the book is served under a subdirectory
|
|
61
|
+
* (e.g. `https://example.com/demo-mdbook/`).
|
|
62
|
+
* Converting them to relative paths (e.g. `../../scalars/id.md`) makes links
|
|
63
|
+
* work correctly regardless of where the book is hosted.
|
|
64
|
+
*/
|
|
65
|
+
export declare const afterRenderTypeEntitiesHook: RenderTypeEntitiesHook;
|
|
55
66
|
/**
|
|
56
67
|
* Creates an mdBook formatter.
|
|
57
68
|
* @param _meta - Unused metadata parameter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdbook/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,eAAe,EACf,QAAQ,EACT,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdbook/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAoBjC;;;;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;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,kBAE1B,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,yEAAyE;AACzE,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAU9C,CAAC;AAEF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAyBrB;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,EAAE,sBAoBzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAW5D,CAAC;AAeF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAiFlC,CAAC"}
|
package/dist/mdbook/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.afterRenderFilesHook = exports.createMDXFormatter = 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.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");
|
|
@@ -86,6 +86,38 @@ var defaults_2 = require("../defaults");
|
|
|
86
86
|
Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
|
|
87
87
|
Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
|
|
88
88
|
Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
|
|
89
|
+
const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
|
|
90
|
+
return content.replaceAll(/\]\((\/[^)\s#]+)(#[^)\s]+)?\)/g, (_match, urlPath, hash = "") => {
|
|
91
|
+
const relativePath = (0, utils_1.toRelativeGeneratedDocLink)({
|
|
92
|
+
baseURL,
|
|
93
|
+
currentFilePath: filePath,
|
|
94
|
+
extension: exports.mdxExtension,
|
|
95
|
+
outputDir,
|
|
96
|
+
targetUrlPath: urlPath,
|
|
97
|
+
});
|
|
98
|
+
const target = relativePath ?? urlPath;
|
|
99
|
+
return `](${target}${hash})`;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Rewrites absolute generated doc links to page-relative `.md` paths after each page is rendered.
|
|
104
|
+
*
|
|
105
|
+
* mdBook resolves links relative to the book source root, so absolute paths
|
|
106
|
+
* like `/graphql/types/scalars/id.md` are rendered as `/graphql/types/scalars/id.html`
|
|
107
|
+
* in the output HTML — which breaks when the book is served under a subdirectory
|
|
108
|
+
* (e.g. `https://example.com/demo-mdbook/`).
|
|
109
|
+
* Converting them to relative paths (e.g. `../../scalars/id.md`) makes links
|
|
110
|
+
* work correctly regardless of where the book is hosted.
|
|
111
|
+
*/
|
|
112
|
+
const afterRenderTypeEntitiesHook = async (event) => {
|
|
113
|
+
const { baseURL, filePath, outputDir } = event.data;
|
|
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
|
+
}
|
|
119
|
+
};
|
|
120
|
+
exports.afterRenderTypeEntitiesHook = afterRenderTypeEntitiesHook;
|
|
89
121
|
/**
|
|
90
122
|
* Creates an mdBook formatter.
|
|
91
123
|
* @param _meta - Unused metadata parameter
|
|
@@ -155,7 +187,7 @@ const afterRenderFilesHook = async (event) => {
|
|
|
155
187
|
"",
|
|
156
188
|
"---",
|
|
157
189
|
"",
|
|
158
|
-
`[GraphQL API Reference](${baseURL}/index${exports.mdxExtension}
|
|
190
|
+
`[GraphQL API Reference](${baseURL}/index${exports.mdxExtension})`,
|
|
159
191
|
"",
|
|
160
192
|
];
|
|
161
193
|
let lastTopSection = null;
|
package/dist/mkdocs/index.d.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
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
11
|
export declare const __default: {
|
|
11
|
-
formatMDXBullet:
|
|
12
|
-
formatMDXLink:
|
|
12
|
+
formatMDXBullet: typeof formatMDXBullet;
|
|
13
|
+
formatMDXLink: typeof formatMDXLink;
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Formats a badge as an inline HTML mark element.
|
|
@@ -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;AAYjC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7D,eAAO,MAAM,SAAS;;;CAGrB,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,sBAoBzC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAW5D,CAAC"}
|
|
@@ -28,34 +28,13 @@ export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
|
|
|
28
28
|
*/
|
|
29
29
|
export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, _meta: Maybe<MetaInfo>) => MDXString;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Returns the link unchanged — Starlight routes `page.mdx` to `page/` so
|
|
32
|
+
* links must not include the `.mdx` extension.
|
|
32
33
|
* @param link - Link data with URL and text
|
|
33
|
-
* @returns
|
|
34
|
+
* @returns Unmodified link
|
|
34
35
|
*/
|
|
35
|
-
export declare const formatMDXLink: (
|
|
36
|
+
export declare const formatMDXLink: (link: TypeLink) => TypeLink;
|
|
36
37
|
export { formatMDXBullet, formatMDXDetails, formatMDXFrontmatter, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
|
|
37
|
-
/**
|
|
38
|
-
* Lifecycle hook that creates an `index.md` file for a category directory
|
|
39
|
-
* before Starlight indexes it. Skips creation if the file already exists.
|
|
40
|
-
* @param event - Hook payload containing the target directory and category name
|
|
41
|
-
*/
|
|
42
|
-
export declare const beforeGenerateIndexMetafileHook: (event: {
|
|
43
|
-
data: {
|
|
44
|
-
dirPath: string;
|
|
45
|
-
category: string;
|
|
46
|
-
};
|
|
47
|
-
}) => Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Lifecycle hook that appends a link entry to the category `index.md`
|
|
50
|
-
* after each type entity page is rendered.
|
|
51
|
-
* @param event - Hook payload containing the entity name and its output file path
|
|
52
|
-
*/
|
|
53
|
-
export declare const afterRenderTypeEntitiesHook: (event: {
|
|
54
|
-
data: {
|
|
55
|
-
name: string;
|
|
56
|
-
filePath: string;
|
|
57
|
-
};
|
|
58
|
-
}) => Promise<void>;
|
|
59
38
|
/**
|
|
60
39
|
* Creates an Astro Starlight formatter.
|
|
61
40
|
* @param _meta - Unused metadata parameter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/starlight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
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;AAUjC,+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,SAW5D,CAAC"}
|
package/dist/starlight/index.js
CHANGED
|
@@ -9,10 +9,7 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createMDXFormatter = exports.
|
|
13
|
-
const node_path_1 = require("node:path");
|
|
14
|
-
const promises_1 = require("node:fs/promises");
|
|
15
|
-
const helpers_1 = require("@graphql-markdown/helpers");
|
|
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;
|
|
16
13
|
const utils_1 = require("@graphql-markdown/utils");
|
|
17
14
|
const defaults_1 = require("../defaults");
|
|
18
15
|
/** File extension used for generated pages. */
|
|
@@ -45,15 +42,13 @@ const formatMDXAdmonition = ({ text, title, type }, _meta) => {
|
|
|
45
42
|
};
|
|
46
43
|
exports.formatMDXAdmonition = formatMDXAdmonition;
|
|
47
44
|
/**
|
|
48
|
-
*
|
|
45
|
+
* Returns the link unchanged — Starlight routes `page.mdx` to `page/` so
|
|
46
|
+
* links must not include the `.mdx` extension.
|
|
49
47
|
* @param link - Link data with URL and text
|
|
50
|
-
* @returns
|
|
48
|
+
* @returns Unmodified link
|
|
51
49
|
*/
|
|
52
|
-
const formatMDXLink = (
|
|
53
|
-
return
|
|
54
|
-
text,
|
|
55
|
-
url: (0, helpers_1.appendLinkExtension)(url, exports.mdxExtension),
|
|
56
|
-
};
|
|
50
|
+
const formatMDXLink = (link) => {
|
|
51
|
+
return link;
|
|
57
52
|
};
|
|
58
53
|
exports.formatMDXLink = formatMDXLink;
|
|
59
54
|
var defaults_2 = require("../defaults");
|
|
@@ -62,37 +57,6 @@ Object.defineProperty(exports, "formatMDXDetails", { enumerable: true, get: func
|
|
|
62
57
|
Object.defineProperty(exports, "formatMDXFrontmatter", { enumerable: true, get: function () { return defaults_2.formatMDXFrontmatter; } });
|
|
63
58
|
Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
|
|
64
59
|
Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
|
|
65
|
-
const INDEX_MD = "index.md";
|
|
66
|
-
/**
|
|
67
|
-
* Lifecycle hook that creates an `index.md` file for a category directory
|
|
68
|
-
* before Starlight indexes it. Skips creation if the file already exists.
|
|
69
|
-
* @param event - Hook payload containing the target directory and category name
|
|
70
|
-
*/
|
|
71
|
-
const beforeGenerateIndexMetafileHook = async (event) => {
|
|
72
|
-
const { dirPath, category } = event.data;
|
|
73
|
-
const filePath = (0, node_path_1.join)(dirPath, INDEX_MD);
|
|
74
|
-
if (await (0, utils_1.fileExists)(filePath)) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const label = (0, utils_1.startCase)(category);
|
|
78
|
-
await (0, utils_1.ensureDir)(dirPath);
|
|
79
|
-
await (0, utils_1.saveFile)(filePath, `---\ntitle: ${label}\n---\n`);
|
|
80
|
-
};
|
|
81
|
-
exports.beforeGenerateIndexMetafileHook = beforeGenerateIndexMetafileHook;
|
|
82
|
-
/**
|
|
83
|
-
* Lifecycle hook that appends a link entry to the category `index.md`
|
|
84
|
-
* after each type entity page is rendered.
|
|
85
|
-
* @param event - Hook payload containing the entity name and its output file path
|
|
86
|
-
*/
|
|
87
|
-
const afterRenderTypeEntitiesHook = async (event) => {
|
|
88
|
-
const { name, filePath } = event.data;
|
|
89
|
-
const indexFilePath = (0, node_path_1.resolve)((0, node_path_1.dirname)(filePath), INDEX_MD);
|
|
90
|
-
const pageFileName = (0, node_path_1.basename)(filePath);
|
|
91
|
-
if (await (0, utils_1.fileExists)(indexFilePath)) {
|
|
92
|
-
await (0, promises_1.appendFile)(indexFilePath, `- [${name}](./${pageFileName})\n`);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
exports.afterRenderTypeEntitiesHook = afterRenderTypeEntitiesHook;
|
|
96
60
|
/**
|
|
97
61
|
* Creates an Astro Starlight formatter.
|
|
98
62
|
* @param _meta - Unused metadata parameter
|
package/dist/vocs/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Vocs formatter for GraphQL documentation output.
|
|
3
3
|
*
|
|
4
4
|
* Produces MDX compatible with Vite/Vocs using its native callout syntax
|
|
5
|
-
* and Material UI Chip components for badges.
|
|
6
5
|
*
|
|
7
6
|
* @packageDocumentation
|
|
8
7
|
*/
|
|
@@ -12,10 +11,10 @@ export declare const mdxDeclaration: MDXString;
|
|
|
12
11
|
/** File extension used for generated pages. */
|
|
13
12
|
export declare const mdxExtension: ".mdx";
|
|
14
13
|
/**
|
|
15
|
-
* Formats a badge using
|
|
16
|
-
* Maps `DEPRECATED` classname to `warning` color; all others use
|
|
14
|
+
* Formats a badge using Vocs native text directive (`:badge[...]`).
|
|
15
|
+
* Maps `DEPRECATED` classname to `warning` color; all others use default.
|
|
17
16
|
* @param badge - Badge data containing text and optional classname
|
|
18
|
-
* @returns Formatted
|
|
17
|
+
* @returns Formatted Vocs badge string
|
|
19
18
|
*/
|
|
20
19
|
export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
|
|
21
20
|
/**
|
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
|
|
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;AASjC,+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,SAW5D,CAAC"}
|
package/dist/vocs/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Vocs formatter for GraphQL documentation output.
|
|
4
4
|
*
|
|
5
5
|
* Produces MDX compatible with Vite/Vocs using its native callout syntax
|
|
6
|
-
* and Material UI Chip components for badges.
|
|
7
6
|
*
|
|
8
7
|
* @packageDocumentation
|
|
9
8
|
*/
|
|
@@ -14,21 +13,19 @@ const utils_1 = require("@graphql-markdown/utils");
|
|
|
14
13
|
const defaults_1 = require("../defaults");
|
|
15
14
|
/** MDX import statement and inline component definitions prepended to every generated file. */
|
|
16
15
|
exports.mdxDeclaration = `
|
|
17
|
-
import Chip from '@mui/material/Chip';
|
|
18
|
-
|
|
19
16
|
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em' }}> ● </span></>
|
|
20
17
|
`;
|
|
21
18
|
/** File extension used for generated pages. */
|
|
22
19
|
exports.mdxExtension = ".mdx";
|
|
23
20
|
/**
|
|
24
|
-
* Formats a badge using
|
|
25
|
-
* Maps `DEPRECATED` classname to `warning` color; all others use
|
|
21
|
+
* Formats a badge using Vocs native text directive (`:badge[...]`).
|
|
22
|
+
* Maps `DEPRECATED` classname to `warning` color; all others use default.
|
|
26
23
|
* @param badge - Badge data containing text and optional classname
|
|
27
|
-
* @returns Formatted
|
|
24
|
+
* @returns Formatted Vocs badge string
|
|
28
25
|
*/
|
|
29
26
|
const formatMDXBadge = ({ text, classname }) => {
|
|
30
|
-
const
|
|
31
|
-
return
|
|
27
|
+
const badgeType = classname === "DEPRECATED" ? "{warning}" : "";
|
|
28
|
+
return `:badge[${text}]${badgeType}`;
|
|
32
29
|
};
|
|
33
30
|
exports.formatMDXBadge = formatMDXBadge;
|
|
34
31
|
/**
|