@graphql-markdown/formatters 1.2.1 → 1.2.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.
@@ -69,7 +69,7 @@ const formatMDXFrontmatter = (props, formatted) => {
69
69
  const id = props && typeof props === "object" && "id" in props
70
70
  ? props.id
71
71
  : undefined;
72
- const uidLine = id ? [` uid: ${id}`] : [];
72
+ const uidLine = id ? [`uid: ${id}`] : [];
73
73
  return [
74
74
  utils_1.FRONT_MATTER_DELIMITER,
75
75
  ...uidLine,
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- import type { AdmonitionType, Badge, Formatter, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
8
+ import type { AdmonitionType, Badge, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
9
9
  import { formatMDXEscapedPermalink } from "../defaults.ts";
10
10
  /**
11
11
  * Formats a permalink for a section header, using the classic `{#id}` syntax
@@ -25,6 +25,20 @@ export declare const formatMDXPermalink: typeof formatMDXEscapedPermalink;
25
25
  export declare const mdxDeclaration: MDXString;
26
26
  /** File extension used for generated pages. */
27
27
  export declare const mdxExtension: ".mdx";
28
+ /**
29
+ * Formats YAML front matter followed by a visible `# Title` heading.
30
+ *
31
+ * Vocs only uses the front matter `title` for the document `<title>`; the
32
+ * page heading must be written in Markdown, so without it generated pages
33
+ * have no visible title.
34
+ *
35
+ * @see https://vocs.dev/docs/markdown
36
+ *
37
+ * @param props - Front matter options
38
+ * @param formatted - Pre-formatted front matter lines
39
+ * @returns Front matter block and title heading, or empty string if no lines provided
40
+ */
41
+ export declare const formatMDXFrontmatter: (props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
28
42
  /**
29
43
  * Formats a badge using Vocs native text directive (`:badge[...]`).
30
44
  * Maps `DEPRECATED` classname to `warning` color; all others use default.
@@ -59,7 +73,7 @@ export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
59
73
  * @returns Formatted JSX entity reference string
60
74
  */
61
75
  export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
62
- export { formatMDXDetails, formatMDXFrontmatter, formatMDXSpecifiedByLink, } from "../defaults.ts";
76
+ export { formatMDXDetails, formatMDXSpecifiedByLink } from "../defaults.ts";
63
77
  /**
64
78
  * Creates a Vocs formatter.
65
79
  * @param _meta - Unused metadata parameter
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAEL,yBAAyB,EAG1B,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,yBACb,CAAC;AAE5B,+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,G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eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxExtension = exports.mdxDeclaration = exports.formatMDXPermalink = void 0;
10
+ exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.formatMDXFrontmatter = exports.mdxExtension = exports.mdxDeclaration = exports.formatMDXPermalink = void 0;
11
11
  const helpers_1 = require("@graphql-markdown/helpers");
12
12
  const utils_1 = require("@graphql-markdown/utils");
13
13
  const defaults_ts_1 = require("../defaults.js");
@@ -31,6 +31,28 @@ export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5
31
31
  `;
32
32
  /** File extension used for generated pages. */
33
33
  exports.mdxExtension = ".mdx";
34
+ /**
35
+ * Formats YAML front matter followed by a visible `# Title` heading.
36
+ *
37
+ * Vocs only uses the front matter `title` for the document `<title>`; the
38
+ * page heading must be written in Markdown, so without it generated pages
39
+ * have no visible title.
40
+ *
41
+ * @see https://vocs.dev/docs/markdown
42
+ *
43
+ * @param props - Front matter options
44
+ * @param formatted - Pre-formatted front matter lines
45
+ * @returns Front matter block and title heading, or empty string if no lines provided
46
+ */
47
+ const formatMDXFrontmatter = (props, formatted) => {
48
+ const frontMatter = (0, defaults_ts_1.formatMDXFrontmatter)(props, formatted);
49
+ const heading = (0, defaults_ts_1.formatMDXFrontmatterTitleOnly)(formatted);
50
+ if (!frontMatter || !heading) {
51
+ return frontMatter;
52
+ }
53
+ return `${frontMatter}${utils_1.MARKDOWN_EOP}${heading}`;
54
+ };
55
+ exports.formatMDXFrontmatter = formatMDXFrontmatter;
34
56
  /**
35
57
  * Formats a badge using Vocs native text directive (`:badge[...]`).
36
58
  * Maps `DEPRECATED` classname to `warning` color; all others use default.
@@ -90,7 +112,6 @@ const formatMDXNameEntity = (name, parentType) => {
90
112
  exports.formatMDXNameEntity = formatMDXNameEntity;
91
113
  var defaults_ts_2 = require("../defaults.js");
92
114
  Object.defineProperty(exports, "formatMDXDetails", { enumerable: true, get: function () { return defaults_ts_2.formatMDXDetails; } });
93
- Object.defineProperty(exports, "formatMDXFrontmatter", { enumerable: true, get: function () { return defaults_ts_2.formatMDXFrontmatter; } });
94
115
  Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_ts_2.formatMDXSpecifiedByLink; } });
95
116
  /**
96
117
  * Creates a Vocs formatter.
@@ -103,7 +124,7 @@ const createMDXFormatter = (_meta) => {
103
124
  formatMDXAdmonition: exports.formatMDXAdmonition,
104
125
  formatMDXBullet: exports.formatMDXBullet,
105
126
  formatMDXDetails: defaults_ts_1.formatMDXDetails,
106
- formatMDXFrontmatter: defaults_ts_1.formatMDXFrontmatter,
127
+ formatMDXFrontmatter: exports.formatMDXFrontmatter,
107
128
  formatMDXLink: exports.formatMDXLink,
108
129
  formatMDXNameEntity: exports.formatMDXNameEntity,
109
130
  formatMDXPermalink: exports.formatMDXPermalink,
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.2.1",
8
+ "version": "1.2.2",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -221,9 +221,9 @@
221
221
  "test:watch": "vitest --watch"
222
222
  },
223
223
  "dependencies": {
224
- "@graphql-markdown/helpers": "^1.2.4",
224
+ "@graphql-markdown/helpers": "^1.2.5",
225
225
  "@graphql-markdown/types": "^1.17.1",
226
- "@graphql-markdown/utils": "^1.14.1"
226
+ "@graphql-markdown/utils": "^1.14.2"
227
227
  },
228
228
  "devDependencies": {
229
229
  "@graphql-markdown/tooling-config": "^1.0.0"