@graphql-markdown/docusaurus 1.30.3 → 1.31.1

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/index.d.ts CHANGED
@@ -4,3 +4,5 @@ import type { GraphQLMarkdownCliOptions } from "@graphql-markdown/types";
4
4
  *
5
5
  */
6
6
  export default function pluginGraphQLDocGenerator(_: LoadContext, options: GraphQLMarkdownCliOptions & Partial<PluginOptions>): Promise<Plugin>;
7
+ export { createMDXFormatter } from "./mdx";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAczE;;GAEG;AACH,wBAA8B,yBAAyB,CACrD,CAAC,EAAE,WAAW,EACd,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC,GAC1D,OAAO,CAAC,MAAM,CAAC,CAyCjB;AAED,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC"}
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createMDXFormatter = void 0;
6
7
  exports.default = pluginGraphQLDocGenerator;
7
8
  const utils_1 = require("@docusaurus/utils");
8
9
  const cli_1 = require("@graphql-markdown/cli");
@@ -46,3 +47,5 @@ async function pluginGraphQLDocGenerator(_, options) {
46
47
  },
47
48
  };
48
49
  }
50
+ const mdx_1 = require("./mdx");
51
+ Object.defineProperty(exports, "createMDXFormatter", { enumerable: true, get: function () { return mdx_1.createMDXFormatter; } });
@@ -2,5 +2,11 @@
2
2
  * @module mdx
3
3
  * This module provides utilities for generating MDX index files in Docusaurus format.
4
4
  */
5
- import type { GenerateIndexMetafileType } from "@graphql-markdown/types";
6
- export declare const generateIndexMetafile: GenerateIndexMetafileType;
5
+ export declare const beforeGenerateIndexMetafileHook: (event: {
6
+ data: {
7
+ dirPath: string;
8
+ category: string;
9
+ options?: Record<string, unknown> | undefined;
10
+ };
11
+ }) => Promise<void>;
12
+ //# sourceMappingURL=category.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../../src/mdx/category.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkBH,eAAO,MAAM,+BAA+B;;;;;;mBAiC3C,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * This module provides utilities for generating MDX index files in Docusaurus format.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.generateIndexMetafile = void 0;
7
+ exports.beforeGenerateIndexMetafileHook = void 0;
8
8
  const node_path_1 = require("node:path");
9
9
  const utils_1 = require("@graphql-markdown/utils");
10
10
  const CATEGORY_YAML = "_category_.yml";
@@ -13,15 +13,18 @@ var SidebarPosition;
13
13
  SidebarPosition[SidebarPosition["FIRST"] = 1] = "FIRST";
14
14
  SidebarPosition[SidebarPosition["LAST"] = 999] = "LAST";
15
15
  })(SidebarPosition || (SidebarPosition = {}));
16
- const generateIndexMetafile = async (dirPath, category, options) => {
16
+ const beforeGenerateIndexMetafileHook = async (event) => {
17
+ const { dirPath, category, options } = event.data;
17
18
  const filePath = (0, node_path_1.join)(dirPath, CATEGORY_YAML);
18
19
  if (await (0, utils_1.fileExists)(filePath)) {
19
20
  return;
20
21
  }
21
22
  const label = (0, utils_1.startCase)(category);
22
- const link = options?.index !== true
23
- ? "null"
24
- : `\n type: generated-index\n title: '${label} overview'`;
23
+ // Docusaurus 3.x uses the directory name as the id automatically
24
+ // No need to explicitly set id field in _category_.yml
25
+ const link = options?.index === true
26
+ ? `\n type: generated-index\n title: '${label} overview'`
27
+ : "null";
25
28
  const className = typeof options?.styleClass === "string"
26
29
  ? `className: ${options.styleClass}\n`
27
30
  : "";
@@ -32,4 +35,4 @@ const generateIndexMetafile = async (dirPath, category, options) => {
32
35
  await (0, utils_1.ensureDir)(dirPath);
33
36
  await (0, utils_1.saveFile)(filePath, content);
34
37
  };
35
- exports.generateIndexMetafile = generateIndexMetafile;
38
+ exports.beforeGenerateIndexMetafileHook = beforeGenerateIndexMetafileHook;
@@ -4,3 +4,4 @@
4
4
  */
5
5
  import type { MDXString } from "@graphql-markdown/types";
6
6
  export declare const mdxDeclaration: MDXString;
7
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/mdx/components.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,eAAO,MAAM,cAAc,EAAE,SA4Bf,CAAC"}
@@ -6,9 +6,14 @@
6
6
  *
7
7
  * @primaryExport
8
8
  */
9
- import type { AdmonitionType, Badge, CollapsibleOption, Maybe, MDXString, MetaOptions, TypeLink } from "@graphql-markdown/types";
9
+ import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
10
  export { mdxDeclaration } from "./components";
11
- export { generateIndexMetafile } from "./category";
11
+ export { beforeGenerateIndexMetafileHook } from "./category";
12
+ /**
13
+ * Formats a Badge inline-block in MDX format
14
+ * @param param - The badge configuration object
15
+ * @returns Formatted MDX string for the badge
16
+ */
12
17
  export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
13
18
  /**
14
19
  * Formats an admonition block in MDX format
@@ -16,7 +21,7 @@ export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
16
21
  * @param meta - Optional metadata for generator configuration
17
22
  * @returns Formatted MDX string for the admonition
18
23
  */
19
- export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, meta: Maybe<MetaOptions>) => MDXString;
24
+ export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, meta: Maybe<MetaInfo>) => MDXString;
20
25
  /**
21
26
  * Creates a bullet point element in MDX format
22
27
  * @param text - Optional text to append after the bullet point
@@ -42,4 +47,38 @@ export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
42
47
  * @returns Formatted MDX string for the name entity
43
48
  */
44
49
  export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
50
+ /**
51
+ * Formats a link in MDX format
52
+ * @param param - The link configuration object
53
+ * @returns Formatted MDX link object
54
+ */
45
55
  export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
56
+ /**
57
+ * Default frontmatter formatter for MDX.
58
+ *
59
+ * @param _props - The front matter options (unused)
60
+ * @param formatted - The formatted front matter as an array of strings
61
+ * @returns Formatted MDX string for the front matter
62
+ */
63
+ export declare const formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
64
+ /**
65
+ * Creates an MDX formatter for Docusaurus documentation.
66
+ *
67
+ * The MDX formatter produces React component-based markup compatible
68
+ * with Docusaurus MDX rendering. It uses components like `<Badge>`,
69
+ * `<Bullet>`, `<Details>`, and `<SpecifiedBy>`.
70
+ *
71
+ * @param meta - Optional metadata for framework-specific formatting
72
+ * @returns A complete Formatter implementation for MDX output
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * import { createMDXFormatter } from '@graphql-markdown/docusaurus';
77
+ *
78
+ * const formatter = createMDXFormatter({ generatorFrameworkName: 'docusaurus' });
79
+ * const badge = formatter.formatMDXBadge({ text: 'Required' });
80
+ * // '<Badge class="badge badge--secondary " text="Required"/>'
81
+ * ```
82
+ */
83
+ export declare const createMDXFormatter: (meta?: Maybe<MetaInfo>) => Formatter;
84
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdx/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;AAWjC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,cAAc,2CAI1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,6EAU/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,8BAE3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,4DAK5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,4BAEpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,yDAM/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,uCAKzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,8EAShC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,uCAU7B,CAAC"}
package/dist/mdx/index.js CHANGED
@@ -8,16 +8,19 @@
8
8
  * @primaryExport
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.generateIndexMetafile = exports.mdxDeclaration = void 0;
11
+ exports.createMDXFormatter = exports.formatMDXFrontmatter = exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.beforeGenerateIndexMetafileHook = exports.mdxDeclaration = void 0;
12
12
  const utils_1 = require("@graphql-markdown/utils");
13
- const MARKDOWN_EOL = "\n";
14
- const MARKDOWN_EOP = `${MARKDOWN_EOL.repeat(2)}`;
15
13
  const LINK_MDX_EXTENSION = ".mdx";
16
14
  const DEFAULT_CSS_CLASSNAME = "badge--secondary";
17
- var components_1 = require("./components");
15
+ const components_1 = require("./components");
18
16
  Object.defineProperty(exports, "mdxDeclaration", { enumerable: true, get: function () { return components_1.mdxDeclaration; } });
19
- var category_1 = require("./category");
20
- Object.defineProperty(exports, "generateIndexMetafile", { enumerable: true, get: function () { return category_1.generateIndexMetafile; } });
17
+ const category_1 = require("./category");
18
+ Object.defineProperty(exports, "beforeGenerateIndexMetafileHook", { enumerable: true, get: function () { return category_1.beforeGenerateIndexMetafileHook; } });
19
+ /**
20
+ * Formats a Badge inline-block in MDX format
21
+ * @param param - The badge configuration object
22
+ * @returns Formatted MDX string for the badge
23
+ */
21
24
  const formatMDXBadge = ({ text, classname }) => {
22
25
  const style = typeof classname === "string" ? `badge--${classname.toLowerCase()}` : "";
23
26
  return `<Badge class="badge ${DEFAULT_CSS_CLASSNAME} ${style}" text="${text}"/>`;
@@ -33,9 +36,9 @@ const formatMDXAdmonition = ({ text, title, type }, meta) => {
33
36
  const isDocusaurus = meta?.generatorFrameworkName === "docusaurus";
34
37
  if (isDocusaurus && meta.generatorFrameworkVersion?.startsWith("2")) {
35
38
  const oldType = type === "warning" ? "caution" : type;
36
- return `${MARKDOWN_EOP}:::${oldType} ${title}${text}:::`;
39
+ return `${utils_1.MARKDOWN_EOP}:::${oldType} ${title}${text}:::`;
37
40
  }
38
- return `${MARKDOWN_EOP}:::${type}[${title}]${text}:::`;
41
+ return `${utils_1.MARKDOWN_EOP}:::${type}[${title}]${text}:::`;
39
42
  };
40
43
  exports.formatMDXAdmonition = formatMDXAdmonition;
41
44
  /**
@@ -53,7 +56,7 @@ exports.formatMDXBullet = formatMDXBullet;
53
56
  * @returns Formatted MDX string for the collapsible section
54
57
  */
55
58
  const formatMDXDetails = ({ dataOpen, dataClose, }) => {
56
- return `${MARKDOWN_EOP}<Details dataOpen="Hide ${dataOpen}" dataClose="Show ${dataClose}">${MARKDOWN_EOP}\r${MARKDOWN_EOP}</Details>${MARKDOWN_EOP}`;
59
+ return `${utils_1.MARKDOWN_EOP}<Details dataOpen="Hide ${dataOpen}" dataClose="Show ${dataClose}">${utils_1.MARKDOWN_EOP}\r${utils_1.MARKDOWN_EOP}</Details>${utils_1.MARKDOWN_EOP}`;
57
60
  };
58
61
  exports.formatMDXDetails = formatMDXDetails;
59
62
  /**
@@ -76,6 +79,11 @@ const formatMDXNameEntity = (name, parentType) => {
76
79
  return `<code style={{ fontWeight: 'normal' }}>${(0, utils_1.escapeMDX)(parentName)}<b>${(0, utils_1.escapeMDX)(name)}</b></code>`;
77
80
  };
78
81
  exports.formatMDXNameEntity = formatMDXNameEntity;
82
+ /**
83
+ * Formats a link in MDX format
84
+ * @param param - The link configuration object
85
+ * @returns Formatted MDX link object
86
+ */
79
87
  const formatMDXLink = ({ text, url }) => {
80
88
  return {
81
89
  text,
@@ -83,3 +91,46 @@ const formatMDXLink = ({ text, url }) => {
83
91
  };
84
92
  };
85
93
  exports.formatMDXLink = formatMDXLink;
94
+ /**
95
+ * Default frontmatter formatter for MDX.
96
+ *
97
+ * @param _props - The front matter options (unused)
98
+ * @param formatted - The formatted front matter as an array of strings
99
+ * @returns Formatted MDX string for the front matter
100
+ */
101
+ const formatMDXFrontmatter = (_props, formatted) => {
102
+ return formatted
103
+ ? [utils_1.FRONT_MATTER_DELIMITER, ...formatted, utils_1.FRONT_MATTER_DELIMITER].join(utils_1.MARKDOWN_EOL)
104
+ : "";
105
+ };
106
+ exports.formatMDXFrontmatter = formatMDXFrontmatter;
107
+ /**
108
+ * Creates an MDX formatter for Docusaurus documentation.
109
+ *
110
+ * The MDX formatter produces React component-based markup compatible
111
+ * with Docusaurus MDX rendering. It uses components like `<Badge>`,
112
+ * `<Bullet>`, `<Details>`, and `<SpecifiedBy>`.
113
+ *
114
+ * @param meta - Optional metadata for framework-specific formatting
115
+ * @returns A complete Formatter implementation for MDX output
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * import { createMDXFormatter } from '@graphql-markdown/docusaurus';
120
+ *
121
+ * const formatter = createMDXFormatter({ generatorFrameworkName: 'docusaurus' });
122
+ * const badge = formatter.formatMDXBadge({ text: 'Required' });
123
+ * // '<Badge class="badge badge--secondary " text="Required"/>'
124
+ * ```
125
+ */
126
+ const createMDXFormatter = (meta) => ({
127
+ formatMDXBadge: exports.formatMDXBadge,
128
+ formatMDXAdmonition: (admonition, _meta) => (0, exports.formatMDXAdmonition)(admonition, meta ?? _meta),
129
+ formatMDXBullet: exports.formatMDXBullet,
130
+ formatMDXDetails: exports.formatMDXDetails,
131
+ formatMDXFrontmatter: exports.formatMDXFrontmatter,
132
+ formatMDXLink: exports.formatMDXLink,
133
+ formatMDXNameEntity: exports.formatMDXNameEntity,
134
+ formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
135
+ });
136
+ exports.createMDXFormatter = createMDXFormatter;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "bugs": {
6
6
  "url": "https://github.com/graphql-markdown/graphql-markdown/issues"
7
7
  },
8
- "version": "1.30.3",
8
+ "version": "1.31.1",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -58,21 +58,20 @@
58
58
  "./package.json": "./package.json"
59
59
  },
60
60
  "scripts": {
61
- "prepack": "pinst --disable",
62
- "postpack": "pinst --enable",
63
61
  "stryker": "stryker run",
64
- "clean": "rm -rf ./dist",
65
- "docs": "typedoc"
62
+ "clean": "tsgo --build --clean && rm -rf ./dist",
63
+ "docs": "typedoc",
64
+ "build": "tsgo --build"
66
65
  },
67
66
  "dependencies": {
68
- "@graphql-markdown/cli": "^0.4.3",
67
+ "@graphql-markdown/cli": "^0.5.0",
69
68
  "@graphql-markdown/logger": "^1.0.5",
70
- "@graphql-markdown/utils": "^1.9.0",
71
- "@docusaurus/utils": ">=3.2.0"
69
+ "@graphql-markdown/utils": "^1.9.1",
70
+ "@docusaurus/utils": ">=3.9.2"
72
71
  },
73
72
  "devDependencies": {
74
73
  "@docusaurus/types": "^3.7.0",
75
- "@graphql-markdown/types": "^1.8.0"
74
+ "@graphql-markdown/types": "^1.9.0"
76
75
  },
77
76
  "peerDependencies": {
78
77
  "@docusaurus/logger": "*"
@@ -81,11 +80,12 @@
81
80
  "test": "tests"
82
81
  },
83
82
  "engines": {
84
- "node": ">=16.14"
83
+ "node": ">=20"
85
84
  },
86
85
  "publishConfig": {
87
86
  "directory": "dist",
88
- "access": "public"
87
+ "access": "public",
88
+ "scripts": {}
89
89
  },
90
90
  "typescript": {
91
91
  "definition": "dist/index.d.ts"