@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.
@@ -60,4 +60,31 @@ export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<stri
60
60
  * @returns Formatted specification link string
61
61
  */
62
62
  export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
63
+ /**
64
+ * Formats a permalink for a section header using the classic `{#id}` syntax,
65
+ * escaped so that it stays valid MDX.
66
+ *
67
+ * MDX parses an unescaped `{` as the start of an expression, and `{#id}` is not
68
+ * a valid one, so presets generating `.mdx` pages must use this variant.
69
+ *
70
+ * @param id - The ID of the section header
71
+ * @returns Formatted permalink string
72
+ *
73
+ * @example
74
+ * ```js
75
+ * formatMDXEscapedPermalink("my-id"); // \{#my-id\}
76
+ * ```
77
+ */
78
+ export declare const formatMDXEscapedPermalink: (id: string) => MDXString;
79
+ /**
80
+ * Formats a permalink for a section header using the classic `{#id}` syntax.
81
+ *
82
+ * This is the syntax supported by most Markdown-based generators (Hugo,
83
+ * mdBook, DocFX, MkDocs with `attr_list`). Presets targeting a framework that
84
+ * expects another syntax override this function.
85
+ *
86
+ * @param id - The ID of the section header
87
+ * @returns Formatted permalink string
88
+ */
89
+ export declare const formatMDXPermalink: (id: string) => MDXString;
63
90
  //# sourceMappingURL=defaults.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAQjC;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAW,KAAK,KAAG,SAE7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,gCACD,cAAc,SACpC,K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;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAE9C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAKF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,OAAQ,MAAM,KAAG,SAEtD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,OAAQ,MAAM,KAAG,SAE/C,CAAC"}
package/dist/defaults.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
11
+ exports.formatMDXPermalink = exports.formatMDXEscapedPermalink = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
12
12
  const helpers_1 = require("@graphql-markdown/helpers");
13
13
  const utils_1 = require("@graphql-markdown/utils");
14
14
  /**
@@ -91,3 +91,36 @@ const formatMDXSpecifiedByLink = (url) => {
91
91
  return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
92
92
  };
93
93
  exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
94
+ /**
95
+ * Formats a permalink for a section header using the classic `{#id}` syntax,
96
+ * escaped so that it stays valid MDX.
97
+ *
98
+ * MDX parses an unescaped `{` as the start of an expression, and `{#id}` is not
99
+ * a valid one, so presets generating `.mdx` pages must use this variant.
100
+ *
101
+ * @param id - The ID of the section header
102
+ * @returns Formatted permalink string
103
+ *
104
+ * @example
105
+ * ```js
106
+ * formatMDXEscapedPermalink("my-id"); // \{#my-id\}
107
+ * ```
108
+ */
109
+ const formatMDXEscapedPermalink = (id) => {
110
+ return String.raw `\{#${id}\}`;
111
+ };
112
+ exports.formatMDXEscapedPermalink = formatMDXEscapedPermalink;
113
+ /**
114
+ * Formats a permalink for a section header using the classic `{#id}` syntax.
115
+ *
116
+ * This is the syntax supported by most Markdown-based generators (Hugo,
117
+ * mdBook, DocFX, MkDocs with `attr_list`). Presets targeting a framework that
118
+ * expects another syntax override this function.
119
+ *
120
+ * @param id - The ID of the section header
121
+ * @returns Formatted permalink string
122
+ */
123
+ const formatMDXPermalink = (id) => {
124
+ return `{#${id}}`;
125
+ };
126
+ exports.formatMDXPermalink = formatMDXPermalink;
@@ -37,20 +37,16 @@ export declare const formatMDXFrontmatter: (props: Maybe<FrontMatterOptions>, fo
37
37
  * @returns The link unchanged
38
38
  */
39
39
  export declare const formatMDXLink: (link: TypeLink) => TypeLink;
40
- export { formatMDXBullet, formatMDXDetails, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
40
+ export { formatMDXBullet, formatMDXDetails, formatMDXNameEntity, formatMDXPermalink, formatMDXSpecifiedByLink, } from "../defaults";
41
41
  /**
42
42
  * Creates a DocFX formatter.
43
43
  * @param _meta - Unused metadata parameter
44
44
  * @returns A complete {@link Formatter} implementation for DocFX output
45
45
  */
46
46
  export declare const createMDXFormatter: (_meta?: Maybe<MetaInfo>) => Formatter;
47
- export declare const mdxExtension: ".md";
48
47
  /**
49
- * Builds DocFX `toc.yml` navigation files as each entity page is written.
50
- *
51
- * Walks up from the generated file to the graphql output root (`outputDir`),
52
- * writing or updating a `toc.yml` at every directory level. Section index pages
53
- * are prepended as an "Overview" entry on first encounter.
48
+ * The file extension used for MDX files in DocFX output.
54
49
  */
50
+ export declare const mdxExtension: ".md";
55
51
  export declare const afterRenderTypeEntitiesHook: RenderTypeEntitiesHook;
56
52
  //# sourceMappingURL=index.d.ts.map
@@ -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;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"}
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,EAEL,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,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAsP3C,eAAO,MAAM,2BAA2B,EAAE,sBAuCzC,CAAC"}
@@ -9,11 +9,12 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.afterRenderTypeEntitiesHook = exports.mdxExtension = exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.BADGE_CLASS_MAP = void 0;
12
+ exports.afterRenderTypeEntitiesHook = exports.mdxExtension = exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXPermalink = exports.formatMDXNameEntity = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.BADGE_CLASS_MAP = void 0;
13
13
  const node_path_1 = require("node:path");
14
14
  const helpers_1 = require("@graphql-markdown/helpers");
15
15
  const utils_1 = require("@graphql-markdown/utils");
16
16
  const defaults_1 = require("../defaults");
17
+ const output_1 = require("../output");
17
18
  /** Maps graphql-markdown admonition types to DocFX alert types. */
18
19
  const ALERT_TYPE_MAP = {
19
20
  note: "NOTE",
@@ -90,6 +91,7 @@ var defaults_2 = require("../defaults");
90
91
  Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
91
92
  Object.defineProperty(exports, "formatMDXDetails", { enumerable: true, get: function () { return defaults_2.formatMDXDetails; } });
92
93
  Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
94
+ Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
93
95
  Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
94
96
  /**
95
97
  * Creates a DocFX formatter.
@@ -105,11 +107,18 @@ const createMDXFormatter = (_meta) => {
105
107
  formatMDXFrontmatter: exports.formatMDXFrontmatter,
106
108
  formatMDXLink: exports.formatMDXLink,
107
109
  formatMDXNameEntity: defaults_1.formatMDXNameEntity,
110
+ formatMDXPermalink: defaults_1.formatMDXPermalink,
108
111
  formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
109
112
  };
110
113
  };
111
114
  exports.createMDXFormatter = createMDXFormatter;
115
+ /**
116
+ * The file extension used for MDX files in DocFX output.
117
+ */
112
118
  exports.mdxExtension = ".md";
119
+ /**
120
+ * Determines if a link is an absolute internal link within the documentation.
121
+ */
113
122
  const isAbsoluteInternalLink = (content, urlStart) => {
114
123
  if (content[urlStart] !== "/")
115
124
  return null;
@@ -121,6 +130,9 @@ const isAbsoluteInternalLink = (content, urlStart) => {
121
130
  return null;
122
131
  return { closePos, urlWithHash };
123
132
  };
133
+ /**
134
+ * Resolves an internal link to its relative path within the generated documentation.
135
+ */
124
136
  const resolveLink = (urlWithHash, filePath, outputDir, normalizedBaseURL, baseSegment) => {
125
137
  const sepIdx = urlWithHash.indexOf("#");
126
138
  const [urlPath, hash] = sepIdx < 0
@@ -140,6 +152,10 @@ const resolveLink = (urlWithHash, filePath, outputDir, normalizedBaseURL, baseSe
140
152
  });
141
153
  return `](${relative ?? urlPath}${hash})`;
142
154
  };
155
+ /**
156
+ * Rewrites all absolute internal links in the content to relative links
157
+ * based on the file's location and the documentation structure.
158
+ */
143
159
  const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
144
160
  const normalizedBaseURL = baseURL.split("/").filter(Boolean).join("/");
145
161
  const baseSegment = `/${normalizedBaseURL}/`;
@@ -166,30 +182,45 @@ const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
166
182
  return out.join("");
167
183
  };
168
184
  // ─── toc.yml builder ────────────────────────────────────────────────────────
185
+ /**
186
+ * Map to track pending write operations for each file.
187
+ * Ensures that concurrent writes to the same file are executed sequentially.
188
+ */
169
189
  const writeQueue = new Map();
190
+ /**
191
+ * Queues a file update to ensure that multiple concurrent writes to the same file
192
+ * are executed sequentially.
193
+ */
170
194
  const queueFileUpdate = async (filePath, update) => {
171
195
  const previous = writeQueue.get(filePath) ?? Promise.resolve();
172
196
  const next = previous.catch(() => { }).then(update);
173
197
  writeQueue.set(filePath, next);
174
198
  return next;
175
199
  };
176
- const updateToc = async (tocFilePath, name, href) => {
200
+ /**
201
+ * Updates the `toc.yml` file for a given directory with a new entry.
202
+ * Ensures that multiple concurrent updates to the same file are queued.
203
+ */
204
+ const updateToc = async (tocFilePath, name, href, outputAdapter) => {
177
205
  await queueFileUpdate(tocFilePath, async () => {
178
206
  const entry = `- name: ${name}${utils_1.MARKDOWN_EOL} href: ${href}`;
179
- if (!(await (0, utils_1.fileExists)(tocFilePath))) {
180
- await (0, utils_1.saveFile)(tocFilePath, entry + utils_1.MARKDOWN_EOL);
207
+ const existing = await (0, output_1.readOptionalOutput)(tocFilePath, outputAdapter);
208
+ if (typeof existing !== "string") {
209
+ await (0, output_1.writeOutput)(tocFilePath, entry + utils_1.MARKDOWN_EOL, outputAdapter);
181
210
  return;
182
211
  }
183
- const existing = await (0, utils_1.readFile)(tocFilePath, "utf-8");
184
212
  if (existing.includes(`href: ${href}`)) {
185
213
  return;
186
214
  }
187
- await (0, utils_1.saveFile)(tocFilePath, existing.trimEnd() + utils_1.MARKDOWN_EOL + entry + utils_1.MARKDOWN_EOL);
215
+ await (0, output_1.writeOutput)(tocFilePath, existing.trimEnd() + utils_1.MARKDOWN_EOL + entry + utils_1.MARKDOWN_EOL, outputAdapter);
188
216
  });
189
217
  };
190
- // Tracks directories whose index.md has already been prepended to their toc.yml.
191
- // Module-level so it persists across all hook invocations within one generation run.
192
- const seenDirectories = new Set();
218
+ // Tracks directories whose index.md has already been prepended to their toc.yml,
219
+ // so the check runs once per directory rather than once per page. Keyed by
220
+ // destination: two adapters writing the same paths keep their own state, and a
221
+ // run with a fresh adapter starts over. `updateToc` skips an href it already
222
+ // holds, so a repeated attempt adds nothing.
223
+ const seenDirectories = new WeakMap();
193
224
  /**
194
225
  * Builds DocFX `toc.yml` navigation files as each entity page is written.
195
226
  *
@@ -197,44 +228,82 @@ const seenDirectories = new Set();
197
228
  * writing or updating a `toc.yml` at every directory level. Section index pages
198
229
  * are prepended as an "Overview" entry on first encounter.
199
230
  */
231
+ /**
232
+ * Adds the "Overview" entry for a directory, the first time it is reached.
233
+ *
234
+ * @param currentDir - Directory whose toc.yml is being built
235
+ * @param tocPath - Path of that toc.yml
236
+ * @param isRoot - Whether the directory is the generated documentation root
237
+ * @param outputAdapter - Destination the pages were written to
238
+ */
239
+ const addOverviewEntry = async (currentDir, tocPath, isRoot, outputAdapter) => {
240
+ if (isRoot) {
241
+ // Homepage is written after hooks run, so add Overview unconditionally.
242
+ await updateToc(tocPath, "Overview", "index.md", outputAdapter);
243
+ return;
244
+ }
245
+ // the section index lives wherever the pages were written, which is not the
246
+ // local filesystem when a custom adapter is configured
247
+ const indexPath = (0, node_path_1.join)(currentDir, "index.md");
248
+ if (typeof (await (0, output_1.readOptionalOutput)(indexPath, outputAdapter)) !== "string") {
249
+ return;
250
+ }
251
+ await updateToc(tocPath, `${(0, utils_1.capitalize)((0, node_path_1.basename)(currentDir))} Overview`, "index.md", outputAdapter);
252
+ };
253
+ /**
254
+ * Adds a page, and every directory above it, to the toc.yml chain.
255
+ *
256
+ * The walk goes up in the same path shape the page was written with: resolving
257
+ * here would hand an adapter an absolute `toc.yml` key next to a relative page
258
+ * key, and a key based destination would file them apart.
259
+ *
260
+ * @param page - The rendered page, its display name and the output root
261
+ * @param outputAdapter - Destination the pages were written to
262
+ */
263
+ const updateTocChain = async (page, outputAdapter) => {
264
+ const { filePath, name, outputDir, pagePath } = page;
265
+ const destination = outputAdapter ?? utils_1.fsOutputAdapter;
266
+ const seen = seenDirectories.get(destination) ?? new Set();
267
+ seenDirectories.set(destination, seen);
268
+ let currentRelativeDir = (0, node_path_1.dirname)(pagePath);
269
+ let currentHref = (0, node_path_1.basename)(filePath);
270
+ let currentName = name;
271
+ for (;;) {
272
+ const isRoot = currentRelativeDir === "." || currentRelativeDir === "";
273
+ const currentDir = isRoot ? outputDir : (0, node_path_1.join)(outputDir, currentRelativeDir);
274
+ const tocPath = (0, node_path_1.join)(currentDir, "toc.yml");
275
+ if (!seen.has(currentDir)) {
276
+ seen.add(currentDir);
277
+ await addOverviewEntry(currentDir, tocPath, isRoot, outputAdapter);
278
+ }
279
+ await updateToc(tocPath, currentName, currentHref, outputAdapter);
280
+ if (isRoot) {
281
+ return;
282
+ }
283
+ currentHref = `${(0, node_path_1.basename)(currentDir)}/toc.yml`;
284
+ currentName = (0, utils_1.capitalize)((0, node_path_1.basename)(currentDir));
285
+ currentRelativeDir = (0, node_path_1.dirname)(currentRelativeDir);
286
+ }
287
+ };
200
288
  const afterRenderTypeEntitiesHook = async (event) => {
201
- const { baseURL, filePath, name, outputDir } = event.data;
202
- const graphqlRoot = (0, node_path_1.resolve)(outputDir);
289
+ const { baseURL, filePath, name, outputAdapter, outputDir } = event.data;
290
+ const pagePath = (0, node_path_1.relative)(outputDir, filePath);
203
291
  // Rewrite uid as a path-derived value to guarantee uniqueness across the site.
204
292
  // e.g. operations/queries/continent.md → uid: operations-queries-continent
205
- const uid = (0, node_path_1.relative)(graphqlRoot, filePath)
206
- .replace(/\.mdx?$/, "")
207
- .replaceAll(/[/\\]/g, "-");
208
- const content = await (0, utils_1.readFile)(filePath, "utf-8");
293
+ const uid = pagePath.replace(/\.mdx?$/, "").replaceAll(/[/\\]/g, "-");
294
+ const content = await (0, output_1.readOutput)(filePath, outputAdapter);
295
+ if (typeof content !== "string") {
296
+ return;
297
+ }
209
298
  const withUid = content.replace(/^(\s*)uid:.*$/m, `$1uid: ${uid}`);
210
299
  const rewritten = rewriteInternalLinks(withUid, filePath, outputDir, baseURL);
211
300
  if (rewritten !== content) {
212
- await (0, utils_1.saveFile)(filePath, rewritten);
301
+ await (0, output_1.writeOutput)(filePath, rewritten, outputAdapter);
213
302
  }
214
- let currentDir = (0, node_path_1.resolve)((0, node_path_1.dirname)(filePath));
215
- let currentHref = (0, node_path_1.basename)(filePath);
216
- let currentName = name;
217
- while (currentDir.startsWith(graphqlRoot)) {
218
- const tocPath = (0, node_path_1.resolve)(currentDir, "toc.yml");
219
- if (!seenDirectories.has(currentDir)) {
220
- seenDirectories.add(currentDir);
221
- if (currentDir === graphqlRoot) {
222
- // Homepage is written after hooks run, so add Overview unconditionally.
223
- await updateToc(tocPath, "Overview", "index.md");
224
- }
225
- else {
226
- const indexPath = (0, node_path_1.resolve)(currentDir, "index.md");
227
- if (await (0, utils_1.fileExists)(indexPath)) {
228
- await updateToc(tocPath, `${(0, utils_1.capitalize)((0, node_path_1.basename)(currentDir))} Overview`, "index.md");
229
- }
230
- }
231
- }
232
- await updateToc(tocPath, currentName, currentHref);
233
- if (currentDir === graphqlRoot)
234
- break;
235
- currentHref = `${(0, node_path_1.basename)(currentDir)}/toc.yml`;
236
- currentName = (0, utils_1.capitalize)((0, node_path_1.basename)(currentDir));
237
- currentDir = (0, node_path_1.dirname)(currentDir);
303
+ // A page outside the output root has no toc to belong to.
304
+ if (pagePath.startsWith("..")) {
305
+ return;
238
306
  }
307
+ await updateTocChain({ filePath, name, outputDir, pagePath }, outputAdapter);
239
308
  };
240
309
  exports.afterRenderTypeEntitiesHook = afterRenderTypeEntitiesHook;
@@ -66,6 +66,22 @@ export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
66
66
  * @returns Formatted front matter block, or empty string if no lines provided
67
67
  */
68
68
  export declare const formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
69
+ /**
70
+ * Formats a permalink for a section header.
71
+ *
72
+ * Docusaurus 3.10 introduced a heading id syntax based on a native MDX comment,
73
+ * and deprecated the classic one. The braces of the comment must NOT be escaped:
74
+ * the heading id is extracted from a real MDX expression node, so an escaped
75
+ * token would be rendered as text. Older versions only support the classic
76
+ * syntax, whose braces must be escaped to remain valid MDX.
77
+ *
78
+ * @see https://docusaurus.io/blog/releases/3.10#strict-heading-ids
79
+ *
80
+ * @param id - The ID of the section header
81
+ * @param meta - Optional metadata used to detect the Docusaurus version
82
+ * @returns Formatted permalink string
83
+ */
84
+ export declare const formatMDXPermalink: (id: string, meta?: Maybe<MetaInfo>) => MDXString;
69
85
  /**
70
86
  * Creates a Docusaurus formatter.
71
87
  * Captures `meta` in closure so `formatMDXAdmonition` can detect the Docusaurus version.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docusaurus/index.ts"],"names":[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ACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAsBjC,mEAAmE;AACnE,eAAO,MAAM,cAAc,EAAE,SAQf,CAAC;AAEf;;;;;GAKG;AACH,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAI3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,QAC/B,KAAK,CAAC,QAAQ,CAAC,KACpB,SAQF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,UAAU,MAAM,KAAQ,SAEnD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAItB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAKvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAMF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,OACzB,MAAM,SACH,KAAK,CAAC,QAAQ,CAAC,KACrB,SAWF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,KAAK,CAAC,QAAQ,CAAC,KAAG,SAmB3D,CAAC"}
@@ -8,10 +8,17 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.createMDXFormatter = exports.formatMDXFrontmatter = exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = void 0;
11
+ exports.createMDXFormatter = exports.formatMDXPermalink = exports.formatMDXFrontmatter = exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = void 0;
12
12
  const helpers_1 = require("@graphql-markdown/helpers");
13
13
  const utils_1 = require("@graphql-markdown/utils");
14
+ const defaults_1 = require("../defaults");
15
+ const version_1 = require("../version");
14
16
  const LINK_MDX_EXTENSION = ".mdx";
17
+ const DOCUSAURUS_FRAMEWORK = "docusaurus";
18
+ /** Docusaurus version using the legacy `:::caution` admonition syntax. */
19
+ const LEGACY_ADMONITION_VERSION = { major: 2 };
20
+ /** Docusaurus version introducing the MDX comment heading id syntax. */
21
+ const MDX_COMMENT_HEADING_ID_VERSION = { major: 3, minor: 10 };
15
22
  const DEFAULT_CSS_CLASSNAME = "badge--secondary";
16
23
  /** MDX component definitions prepended to every generated file. */
17
24
  exports.mdxDeclaration = `
@@ -42,8 +49,7 @@ exports.formatMDXBadge = formatMDXBadge;
42
49
  * @returns Formatted admonition string
43
50
  */
44
51
  const formatMDXAdmonition = ({ text, title, type }, meta) => {
45
- const isDocusaurus = meta?.generatorFrameworkName === "docusaurus";
46
- if (isDocusaurus && meta.generatorFrameworkVersion?.startsWith("2")) {
52
+ if ((0, version_1.isFrameworkVersion)(meta, DOCUSAURUS_FRAMEWORK, LEGACY_ADMONITION_VERSION)) {
47
53
  const oldType = type === "warning" ? "caution" : type;
48
54
  return `${utils_1.MARKDOWN_EOP}:::${oldType} ${title}${text}:::`;
49
55
  }
@@ -116,6 +122,28 @@ const formatMDXFrontmatter = (_props, formatted) => {
116
122
  return (0, helpers_1.formatMarkdownFrontmatter)(formatted, utils_1.FRONT_MATTER_DELIMITER, utils_1.MARKDOWN_EOL);
117
123
  };
118
124
  exports.formatMDXFrontmatter = formatMDXFrontmatter;
125
+ /**
126
+ * Formats a permalink for a section header.
127
+ *
128
+ * Docusaurus 3.10 introduced a heading id syntax based on a native MDX comment,
129
+ * and deprecated the classic one. The braces of the comment must NOT be escaped:
130
+ * the heading id is extracted from a real MDX expression node, so an escaped
131
+ * token would be rendered as text. Older versions only support the classic
132
+ * syntax, whose braces must be escaped to remain valid MDX.
133
+ *
134
+ * @see https://docusaurus.io/blog/releases/3.10#strict-heading-ids
135
+ *
136
+ * @param id - The ID of the section header
137
+ * @param meta - Optional metadata used to detect the Docusaurus version
138
+ * @returns Formatted permalink string
139
+ */
140
+ const formatMDXPermalink = (id, meta) => {
141
+ if ((0, version_1.isFrameworkVersionAtLeast)(meta, DOCUSAURUS_FRAMEWORK, MDX_COMMENT_HEADING_ID_VERSION)) {
142
+ return `{/* #${id} */}`;
143
+ }
144
+ return (0, defaults_1.formatMDXEscapedPermalink)(id);
145
+ };
146
+ exports.formatMDXPermalink = formatMDXPermalink;
119
147
  /**
120
148
  * Creates a Docusaurus formatter.
121
149
  * Captures `meta` in closure so `formatMDXAdmonition` can detect the Docusaurus version.
@@ -133,6 +161,9 @@ const createMDXFormatter = (meta) => {
133
161
  formatMDXFrontmatter: exports.formatMDXFrontmatter,
134
162
  formatMDXLink: exports.formatMDXLink,
135
163
  formatMDXNameEntity: exports.formatMDXNameEntity,
164
+ formatMDXPermalink: (id) => {
165
+ return (0, exports.formatMDXPermalink)(id, meta);
166
+ },
136
167
  formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
137
168
  };
138
169
  };
@@ -7,6 +7,15 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
  import type { AdmonitionType, Badge, Formatter, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
+ /**
11
+ * Formats a permalink for a section header using the Fumadocs `[#id]` syntax.
12
+ *
13
+ * @see https://www.fumadocs.dev/docs/headless/mdx/headings
14
+ *
15
+ * @param id - The ID of the section header
16
+ * @returns Formatted permalink string
17
+ */
18
+ export declare const formatMDXPermalink: (id: string) => MDXString;
10
19
  /** File extension used for generated pages. */
11
20
  export declare const mdxExtension: ".mdx";
12
21
  /** MDX import statement prepended to every generated file to register Fumadocs and MUI components. */
@@ -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;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"}
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;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,OAAQ,MAAM,KAAG,SAE/C,CAAC;AAEF,+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,SAY5D,CAAC"}
@@ -8,9 +8,21 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
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;
11
+ 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;
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 Fumadocs `[#id]` syntax.
16
+ *
17
+ * @see https://www.fumadocs.dev/docs/headless/mdx/headings
18
+ *
19
+ * @param id - The ID of the section header
20
+ * @returns Formatted permalink string
21
+ */
22
+ const formatMDXPermalink = (id) => {
23
+ return `[#${id}]`;
24
+ };
25
+ exports.formatMDXPermalink = formatMDXPermalink;
14
26
  /** File extension used for generated pages. */
15
27
  exports.mdxExtension = ".mdx";
16
28
  /** MDX import statement prepended to every generated file to register Fumadocs and MUI 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
  };
@@ -7,9 +7,11 @@
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
+ import { formatMDXBullet, formatMDXPermalink } from "../defaults";
11
+ export { formatMDXPermalink } from "../defaults";
11
12
  export declare const __default: {
12
13
  formatMDXBullet: typeof formatMDXBullet;
14
+ formatMDXPermalink: typeof formatMDXPermalink;
13
15
  };
14
16
  /** File extension used for generated pages — HonKit renders plain Markdown to HTML. */
15
17
  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;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,eAA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C;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,SAY5D,CAAC"}
@@ -8,11 +8,13 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxExtension = exports.__default = void 0;
11
+ exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxExtension = exports.__default = exports.formatMDXPermalink = 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
- exports.__default = { formatMDXBullet: defaults_1.formatMDXBullet };
15
+ var defaults_2 = require("../defaults");
16
+ Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
17
+ exports.__default = { formatMDXBullet: defaults_1.formatMDXBullet, formatMDXPermalink: defaults_1.formatMDXPermalink };
16
18
  /** File extension used for generated pages — HonKit renders plain Markdown to HTML. */
17
19
  exports.mdxExtension = ".md";
18
20
  /** Shared default badge theme used across this preset. */
@@ -129,6 +131,7 @@ const createMDXFormatter = (_meta) => {
129
131
  formatMDXFrontmatter: exports.formatMDXFrontmatter,
130
132
  formatMDXLink: exports.formatMDXLink,
131
133
  formatMDXNameEntity: exports.formatMDXNameEntity,
134
+ formatMDXPermalink: defaults_1.formatMDXPermalink,
132
135
  formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
133
136
  };
134
137
  };
@@ -49,7 +49,7 @@ export declare const formatMDXFrontmatter: (props: Maybe<FrontMatterOptions>, fo
49
49
  * @returns Link object with the cleaned URL
50
50
  */
51
51
  export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
52
- export { formatMDXBullet, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
52
+ export { formatMDXBullet, formatMDXNameEntity, formatMDXPermalink, formatMDXSpecifiedByLink, } from "../defaults";
53
53
  /**
54
54
  * Creates a Hugo formatter.
55
55
  * @param _meta - Unused metadata parameter
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hugo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAmCjC;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SAEhD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc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AAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAKvD,CAAC;AAEF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,yBAgB3C,CAAC"}
@@ -9,11 +9,12 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.beforeGenerateIndexMetafileHook = exports.mdxExtension = exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
12
+ exports.beforeGenerateIndexMetafileHook = exports.mdxExtension = exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXPermalink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
13
13
  const node_path_1 = require("node:path");
14
14
  const helpers_1 = require("@graphql-markdown/helpers");
15
15
  const utils_1 = require("@graphql-markdown/utils");
16
16
  const defaults_1 = require("../defaults");
17
+ const output_1 = require("../output");
17
18
  /**
18
19
  * Maps graphql-markdown admonition types to Hugo GitHub-style alert types (Hugo 0.132+).
19
20
  * @see https://gohugo.io/render-hooks/blockquotes/#alerts
@@ -103,6 +104,7 @@ exports.formatMDXLink = formatMDXLink;
103
104
  var defaults_2 = require("../defaults");
104
105
  Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
105
106
  Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
107
+ Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
106
108
  Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
107
109
  /**
108
110
  * Creates a Hugo formatter.
@@ -118,6 +120,7 @@ const createMDXFormatter = (_meta) => {
118
120
  formatMDXFrontmatter: exports.formatMDXFrontmatter,
119
121
  formatMDXLink: exports.formatMDXLink,
120
122
  formatMDXNameEntity: defaults_1.formatMDXNameEntity,
123
+ formatMDXPermalink: defaults_1.formatMDXPermalink,
121
124
  formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
122
125
  };
123
126
  };
@@ -133,11 +136,10 @@ exports.mdxExtension = ".md";
133
136
  * @param event - Hook event whose `data` contains `dirPath` (target directory) and `category` (section name)
134
137
  */
135
138
  const beforeGenerateIndexMetafileHook = async (event) => {
136
- const { dirPath, category } = event.data;
139
+ const { dirPath, category, outputAdapter } = event.data;
137
140
  const filePath = (0, node_path_1.join)(dirPath, "_index.md");
138
141
  const label = (0, utils_1.startCase)(category);
139
142
  const content = `${utils_1.FRONT_MATTER_DELIMITER}${utils_1.MARKDOWN_EOL}title: "${label}"${utils_1.MARKDOWN_EOL}type: docs${utils_1.MARKDOWN_EOL}bookCollapseSection: true${utils_1.MARKDOWN_EOL}${utils_1.FRONT_MATTER_DELIMITER}${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}# ${label}${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}`;
140
- await (0, utils_1.ensureDir)(dirPath);
141
- await (0, utils_1.saveFile)(filePath, content);
143
+ await (0, output_1.writeOutput)(filePath, content, outputAdapter, dirPath);
142
144
  };
143
145
  exports.beforeGenerateIndexMetafileHook = beforeGenerateIndexMetafileHook;
@@ -51,7 +51,7 @@ export declare const mdxExtension = ".md";
51
51
  * @returns The link with `.md` appended to extensionless absolute paths
52
52
  */
53
53
  export declare const formatMDXLink: (link: TypeLink) => TypeLink;
54
- export { formatMDXBullet, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
54
+ export { formatMDXBullet, formatMDXNameEntity, formatMDXPermalink, formatMDXSpecifiedByLink, } from "../defaults";
55
55
  /**
56
56
  * Rewrites absolute generated doc links to page-relative `.md` paths after each page is rendered.
57
57
  *
@@ -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,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;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