@graphql-markdown/nuxt-theme 0.1.0 → 0.1.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.
|
@@ -19,7 +19,7 @@ interface RawPage {
|
|
|
19
19
|
path: string;
|
|
20
20
|
title: string;
|
|
21
21
|
isDeprecated: boolean;
|
|
22
|
-
/** The GraphQL entity kind (`objects`, `scalars`, `queries`, …) stamped by `formatter.
|
|
22
|
+
/** The GraphQL entity kind (`objects`, `scalars`, `queries`, …) stamped by `formatter.mjs`'s `formatMDXFrontmatter`. */
|
|
23
23
|
kind?: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -63,7 +63,7 @@ export interface ApiSinglePageBucket {
|
|
|
63
63
|
interface RawPage {
|
|
64
64
|
path: string;
|
|
65
65
|
title: string;
|
|
66
|
-
/** Undeclared custom frontmatter, stamped by `formatter.
|
|
66
|
+
/** Undeclared custom frontmatter, stamped by `formatter.mjs`; Nuxt Content
|
|
67
67
|
* surfaces it under `meta`, not as a top-level field. */
|
|
68
68
|
kind?: string;
|
|
69
69
|
body: { [key: string]: unknown; value: MdcNode[] };
|
package/constants.ts
ADDED
|
@@ -1,39 +1,55 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Formatter overrides handed to `graphql-markdown` (see `generate.ts`).
|
|
3
5
|
*
|
|
4
|
-
* The library loads this module by URL
|
|
6
|
+
* The library loads this module by URL with a native `import()` at
|
|
7
|
+
* generation time, and Node refuses to strip types from files under
|
|
8
|
+
* `node_modules` — so it ships as plain JS (typed via JSDoc), or every npm
|
|
9
|
+
* install would silently fall back to the default formatter. It is typed
|
|
5
10
|
* structurally: `@graphql-markdown/types` is not a direct dependency, and its
|
|
6
11
|
* `MDXString` return type is opaque and cannot be produced from here.
|
|
7
12
|
*/
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} Badge
|
|
16
|
+
* @property {string} text
|
|
17
|
+
* @property {string[] | string} [classname]
|
|
18
|
+
*/
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {object} Admonition
|
|
22
|
+
* @property {string | null} [icon]
|
|
23
|
+
* @property {string} text
|
|
24
|
+
* @property {string | null} title
|
|
25
|
+
* @property {string} type
|
|
26
|
+
*/
|
|
20
27
|
|
|
21
|
-
/**
|
|
22
|
-
|
|
28
|
+
/**
|
|
29
|
+
* ` · ` instead of the default ` ● `, as text rather than a styled span.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} [text]
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
export const formatMDXBullet = (text = "") => {
|
|
23
35
|
return ` · ${text}`;
|
|
24
36
|
};
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
/**
|
|
39
|
+
* @param {Badge} badge
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
export const formatMDXBadge = ({ text }) => {
|
|
27
43
|
const suffix = String(text).toLowerCase();
|
|
28
44
|
|
|
29
45
|
return `<mark class="gqlmd-mdx-badge gqlmd-mdx-badge-${suffix}">${text}</mark>`;
|
|
30
46
|
};
|
|
31
47
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
48
|
+
/**
|
|
49
|
+
* @param {Admonition} admonition
|
|
50
|
+
* @returns {string}
|
|
51
|
+
*/
|
|
52
|
+
export const formatMDXAdmonition = ({ text, title, type }) => {
|
|
37
53
|
if (
|
|
38
54
|
type.toLowerCase() === "warning" &&
|
|
39
55
|
title?.toLowerCase() === "deprecated"
|
|
@@ -63,12 +79,13 @@ export const mdxExtension = ".md";
|
|
|
63
79
|
* grid by entity kind whenever a page has no folder segments left to group
|
|
64
80
|
* by — today, that's `printTypeOptions.hierarchy: "flat"`, which otherwise
|
|
65
81
|
* has nothing else to group on.
|
|
82
|
+
*
|
|
83
|
+
* @param {unknown} _props
|
|
84
|
+
* @param {string[] | null | undefined} formatted
|
|
85
|
+
* @param {{ entity?: string | null }} [context]
|
|
86
|
+
* @returns {string}
|
|
66
87
|
*/
|
|
67
|
-
export const formatMDXFrontmatter = (
|
|
68
|
-
_props: unknown,
|
|
69
|
-
formatted: string[] | null | undefined,
|
|
70
|
-
context?: { entity?: string | null },
|
|
71
|
-
): string => {
|
|
88
|
+
export const formatMDXFrontmatter = (_props, formatted, context) => {
|
|
72
89
|
if (!formatted) return "";
|
|
73
90
|
const lines = context?.entity
|
|
74
91
|
? [...formatted, `kind: ${context.entity}`]
|
package/generate.ts
CHANGED
|
@@ -28,7 +28,7 @@ const DEFAULT_LOADERS = {
|
|
|
28
28
|
* - baseURL: Base URL for the API reference (default: "api-reference")
|
|
29
29
|
* - printTypeOptions: Formatting options merged with defaults
|
|
30
30
|
* - decorators: Custom decorators for the schema output
|
|
31
|
-
* - formatter: Path/URL to custom formatter module (default: this package's formatter.
|
|
31
|
+
* - formatter: Path/URL to custom formatter module (default: this package's formatter.mjs)
|
|
32
32
|
* - loaders: Custom schema loaders (default: GraphQLFileLoader)
|
|
33
33
|
* @returns A function that generates the documentation when called
|
|
34
34
|
*/
|
|
@@ -47,7 +47,7 @@ export const createGenerateDocs = (userOptions: {
|
|
|
47
47
|
baseURL = DEFAULT_BASE_URL,
|
|
48
48
|
printTypeOptions,
|
|
49
49
|
decorators,
|
|
50
|
-
formatter = new URL("./formatter.
|
|
50
|
+
formatter = new URL("./formatter.mjs", import.meta.url).href,
|
|
51
51
|
loaders = DEFAULT_LOADERS,
|
|
52
52
|
} = userOptions;
|
|
53
53
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-markdown/nuxt-theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A Nuxt layer for building GraphQL API reference sites",
|
|
5
5
|
"homepage": "https://graphql-markdown.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "echo \"no build step — Nuxt layer ships source\"",
|
|
37
|
-
"lint": "eslint --config ../../packages/tooling-config/eslint/config.ts \"app/**/*.{ts,vue}\" \"modules/**/*.ts\" \"*.ts\" \"bin/**/*.mjs\" \"tests/**/*.ts\" --ignore-pattern \"tests/fixture*/**\"",
|
|
38
|
-
"lint:fix": "eslint --config ../../packages/tooling-config/eslint/config.ts \"app/**/*.{ts,vue}\" \"modules/**/*.ts\" \"*.ts\" \"bin/**/*.mjs\" \"tests/**/*.ts\" --ignore-pattern \"tests/fixture*/**\" --fix",
|
|
39
|
-
"prettier": "prettier \"app/**/*.{ts,vue,css}\" \"modules/**/*.ts\" \"*.ts\" \"bin/**/*.mjs\" \"tests/**/*.ts\" \"!tests/fixture*/**\" --check",
|
|
40
|
-
"prettier:fix": "prettier \"app/**/*.{ts,vue,css}\" \"modules/**/*.ts\" \"*.ts\" \"bin/**/*.mjs\" \"tests/**/*.ts\" \"!tests/fixture*/**\" --write",
|
|
37
|
+
"lint": "eslint --config ../../packages/tooling-config/eslint/config.ts \"app/**/*.{ts,vue}\" \"modules/**/*.ts\" \"*.ts\" \"*.mjs\" \"bin/**/*.mjs\" \"tests/**/*.ts\" --ignore-pattern \"tests/fixture*/**\"",
|
|
38
|
+
"lint:fix": "eslint --config ../../packages/tooling-config/eslint/config.ts \"app/**/*.{ts,vue}\" \"modules/**/*.ts\" \"*.ts\" \"*.mjs\" \"bin/**/*.mjs\" \"tests/**/*.ts\" --ignore-pattern \"tests/fixture*/**\" --fix",
|
|
39
|
+
"prettier": "prettier \"app/**/*.{ts,vue,css}\" \"modules/**/*.ts\" \"*.ts\" \"*.mjs\" \"bin/**/*.mjs\" \"tests/**/*.ts\" \"!tests/fixture*/**\" --check",
|
|
40
|
+
"prettier:fix": "prettier \"app/**/*.{ts,vue,css}\" \"modules/**/*.ts\" \"*.ts\" \"*.mjs\" \"bin/**/*.mjs\" \"tests/**/*.ts\" \"!tests/fixture*/**\" --write",
|
|
41
41
|
"ts:check": "nuxi typecheck",
|
|
42
42
|
"test": "vitest run --passWithNoTests",
|
|
43
43
|
"test:unit": "vitest run --passWithNoTests tests/unit",
|
|
@@ -73,8 +73,9 @@
|
|
|
73
73
|
"app",
|
|
74
74
|
"modules",
|
|
75
75
|
"bin",
|
|
76
|
+
"constants.ts",
|
|
76
77
|
"content.config.ts",
|
|
77
|
-
"formatter.
|
|
78
|
+
"formatter.mjs",
|
|
78
79
|
"generate.ts",
|
|
79
80
|
"nuxt.config.ts",
|
|
80
81
|
"swizzle.manifest.ts",
|