@graphql-markdown/docusaurus 1.35.2 → 1.36.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/mdx/category.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
|
+
import type { OutputAdapter } from "@graphql-markdown/types";
|
|
7
8
|
/**
|
|
8
9
|
* Hook that materializes a `_category_.yml` file before Docusaurus indexes
|
|
9
10
|
* a directory, ensuring generated bundles have labels, ordering, and
|
|
@@ -15,6 +16,7 @@ export declare const beforeGenerateIndexMetafileHook: (event: {
|
|
|
15
16
|
data: {
|
|
16
17
|
dirPath: string;
|
|
17
18
|
category: string;
|
|
19
|
+
outputAdapter?: OutputAdapter;
|
|
18
20
|
options?: Record<string, unknown>;
|
|
19
21
|
};
|
|
20
22
|
}) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../../src/mdx/category.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../../src/mdx/category.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAU7D;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,UAAiB;IAC3D,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,CAAC;CACH,KAAG,OAAO,CAAC,IAAI,CA+Bf,CAAC"}
|
package/dist/mdx/category.js
CHANGED
|
@@ -23,9 +23,13 @@ var SidebarPosition;
|
|
|
23
23
|
* @param event - Hook payload containing the target directory, category name, and generator options.
|
|
24
24
|
*/
|
|
25
25
|
const beforeGenerateIndexMetafileHook = async (event) => {
|
|
26
|
-
const { dirPath, category, options } = event.data;
|
|
26
|
+
const { dirPath, category, options, outputAdapter } = event.data;
|
|
27
27
|
const filePath = (0, node_path_1.join)(dirPath, CATEGORY_YAML);
|
|
28
|
-
|
|
28
|
+
// the metafile goes to the same destination as the pages, so a custom output
|
|
29
|
+
// adapter keeps the sidebar metadata alongside what it wrote
|
|
30
|
+
const adapter = outputAdapter ?? utils_1.fsOutputAdapter;
|
|
31
|
+
// preserve a metafile that is already there
|
|
32
|
+
if (typeof (await adapter.readFile(filePath)) === "string") {
|
|
29
33
|
return;
|
|
30
34
|
}
|
|
31
35
|
const label = (0, utils_1.startCase)(category);
|
|
@@ -41,7 +45,7 @@ const beforeGenerateIndexMetafileHook = async (event) => {
|
|
|
41
45
|
? options.sidebarPosition
|
|
42
46
|
: SidebarPosition.FIRST;
|
|
43
47
|
const content = `label: ${label}\nposition: ${position}\n${className}link: ${link}\ncollapsible: ${Boolean(options?.collapsible ?? true)}\ncollapsed: ${Boolean(options?.collapsed ?? true)}\n`;
|
|
44
|
-
await
|
|
45
|
-
await
|
|
48
|
+
await adapter.ensureDir?.(dirPath);
|
|
49
|
+
await adapter.writeFile(filePath, content);
|
|
46
50
|
};
|
|
47
51
|
exports.beforeGenerateIndexMetafileHook = beforeGenerateIndexMetafileHook;
|