Skip to content

Commit 007f3f2

Browse files
authored
update docs to use Nextra 4 (#2726)
* move * rename * more * more * more * more * more * more * more * moree * moree * moree * moree * more * more * more * [skip ci] * more * fix icons * update docs to use Nextra 4 * [skip ci] * fix lint [skip ci] * more [skip ci] * more * upd * pnpm dedupe * yoyo * aa * aa * build pass
1 parent 892f7e3 commit 007f3f2

File tree

133 files changed

+789
-970
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+789
-970
lines changed

.eslintrc.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,11 @@ module.exports = {
119119
'no-undef': 'off',
120120
},
121121
},
122+
{
123+
files: ['website/**/*.mdx/**'],
124+
rules: {
125+
'import/no-default-export': 'off',
126+
},
127+
},
122128
],
123129
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"prettier": "3.3.3",
4646
"prettier-plugin-tailwindcss": "0.6.9",
4747
"rimraf": "6.0.1",
48-
"tsup": "^8.0.0",
48+
"tsup": "^8.3.5",
4949
"tsx": "4.19.2",
5050
"turbo": "2.3.1",
5151
"typescript": "5.6.3",

pnpm-lock.yaml

Lines changed: 109 additions & 238 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate-docs.ts

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { rules } from '../packages/plugin/src/index.js';
1111
const BR = '';
1212
const NBSP = ' ';
1313
const __dirname = fileURLToPath(new URL('.', import.meta.url));
14-
const RULES_PATH = resolve(__dirname, '..', 'website', 'src', 'pages', 'rules');
14+
const RULES_PATH = resolve(__dirname, '..', 'website', 'content', 'rules');
1515

1616
enum Icon {
1717
SCHEMA = '📄',
@@ -52,7 +52,6 @@ const MARKDOWN_LINK_RE = /\[(.*?)]\(.*\)/;
5252

5353
async function generateDocs(): Promise<void> {
5454
const prettierConfigMd = await prettier.resolveConfig('./README.md');
55-
const prettierConfigTs = await prettier.resolveConfig('./_meta.ts');
5655

5756
const result = Object.entries(rules).map(async ([ruleName, rule]) => {
5857
const frontMatterDescription = rule.meta
@@ -101,7 +100,7 @@ async function generateDocs(): Promise<void> {
101100
`- Requires GraphQL Schema: \`${requiresSchema}\` [ℹ️](/docs/getting-started#extended-linting-rules-with-graphql-schema)`,
102101
`- Requires GraphQL Operations: \`${requiresSiblings}\` [ℹ️](/docs/getting-started#extended-linting-rules-with-siblings-operations)`,
103102
BR,
104-
docs.description === frontMatterDescription ? '{frontMatter.description}' : docs.description,
103+
docs.description === frontMatterDescription ? '{metadata.description}' : docs.description,
105104
);
106105

107106
if (docs.examples?.length > 0) {
@@ -237,60 +236,6 @@ async function generateDocs(): Promise<void> {
237236
);
238237
}
239238

240-
const { schemaRules, operationsRules, schemaAndOperationsRules } = Object.entries(rules)
241-
.sort(([a], [b]) => a.localeCompare(b))
242-
.reduce<{
243-
schemaRules: string[];
244-
operationsRules: string[];
245-
schemaAndOperationsRules: [];
246-
}>(
247-
(acc, [ruleId, curr]) => {
248-
const { category } = curr.meta.docs;
249-
if (category === 'Schema') {
250-
acc.schemaRules.push(ruleId);
251-
} else if (category === 'Operations') {
252-
acc.operationsRules.push(ruleId);
253-
} else {
254-
acc.schemaAndOperationsRules.push(ruleId);
255-
}
256-
return acc;
257-
},
258-
{ schemaRules: [], operationsRules: [], schemaAndOperationsRules: [] },
259-
);
260-
const metaJson = {
261-
index: {
262-
title: 'Overview',
263-
theme: {
264-
layout: 'full',
265-
},
266-
},
267-
prettier: '`prettier` Rule',
268-
'deprecated-rules': 'Deprecated Rules',
269-
'---1': {
270-
title: 'Schema & Operations Rules',
271-
type: 'separator',
272-
},
273-
...Object.fromEntries(schemaAndOperationsRules.map(key => [key, ''])),
274-
'---2': {
275-
title: 'Schema Rules',
276-
type: 'separator',
277-
},
278-
...Object.fromEntries(schemaRules.map(key => [key, ''])),
279-
'---3': {
280-
title: 'Operations Rules',
281-
type: 'separator',
282-
},
283-
...Object.fromEntries(operationsRules.map(key => [key, ''])),
284-
};
285-
286-
writeFile(
287-
resolve(RULES_PATH, '_meta.ts'),
288-
await prettier.format('export default ' + JSON.stringify(metaJson), {
289-
parser: 'typescript',
290-
...prettierConfigTs,
291-
}),
292-
);
293-
294239
console.log('✅ Documentation generated');
295240
}
296241

website/app/[[...mdxPath]]/page.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable react-hooks/rules-of-hooks -- false positive, useMDXComponents are not react hooks */
2+
3+
import { generateStaticParamsFor, importPage } from '@theguild/components/pages';
4+
import { useMDXComponents } from '../../mdx-components';
5+
6+
export const generateStaticParams = generateStaticParamsFor('mdxPath');
7+
8+
export async function generateMetadata(props: Props) {
9+
const params = await props.params;
10+
const { metadata } = await importPage(params.mdxPath);
11+
return metadata;
12+
}
13+
14+
const Wrapper = useMDXComponents().wrapper;
15+
16+
type Props = {
17+
params: Promise<{
18+
mdxPath: string[];
19+
}>;
20+
};
21+
22+
export default async function Page(props: Props) {
23+
const params = await props.params;
24+
const result = await importPage(params.mdxPath);
25+
const { default: MDXContent, toc, metadata } = result;
26+
return (
27+
<Wrapper toc={toc} metadata={metadata}>
28+
<MDXContent {...props} params={params} />
29+
</Wrapper>
30+
);
31+
}

website/app/_meta.global.ts

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { rules } from '@graphql-eslint/eslint-plugin';
2+
3+
const { schemaRules, operationsRules, schemaAndOperationsRules } = Object.entries(rules)
4+
.sort(([a], [b]) => a.localeCompare(b))
5+
.reduce<{
6+
schemaRules: string[];
7+
operationsRules: string[];
8+
schemaAndOperationsRules: [];
9+
}>(
10+
(acc, [ruleId, curr]) => {
11+
// @ts-expect-error -- fixme
12+
const { category } = curr.meta.docs;
13+
if (category === 'Schema') {
14+
acc.schemaRules.push(ruleId);
15+
} else if (category === 'Operations') {
16+
acc.operationsRules.push(ruleId);
17+
} else {
18+
// @ts-expect-error -- fixme
19+
acc.schemaAndOperationsRules.push(ruleId);
20+
}
21+
return acc;
22+
},
23+
{ schemaRules: [], operationsRules: [], schemaAndOperationsRules: [] },
24+
);
25+
26+
export default {
27+
docs: {
28+
title: 'Documentation',
29+
type: 'page',
30+
items: {
31+
index: '',
32+
'getting-started': '',
33+
'parser-options': '',
34+
usage: {
35+
title: 'Usage',
36+
items: {
37+
_1: {
38+
type: 'separator',
39+
title: 'Basic',
40+
},
41+
graphql: '',
42+
js: '',
43+
'schema-and-documents': '',
44+
'multiple-projects': '',
45+
programmatic: '',
46+
_2: {
47+
type: 'separator',
48+
title: 'Advanced',
49+
},
50+
svelte: '',
51+
vue: '',
52+
astro: '',
53+
prettier: '',
54+
},
55+
},
56+
_1: {
57+
type: 'separator',
58+
title: 'Users',
59+
},
60+
configs: '',
61+
'disabling-rules': '',
62+
vscode: '',
63+
_2: {
64+
type: 'separator',
65+
title: 'Developers',
66+
},
67+
parser: '',
68+
'custom-rules': '',
69+
},
70+
},
71+
rules: {
72+
title: 'Rules',
73+
type: 'page',
74+
items: {
75+
index: {
76+
theme: {
77+
layout: 'full',
78+
},
79+
},
80+
prettier: '',
81+
'deprecated-rules': '',
82+
_1: {
83+
title: 'Schema & Operations Rules',
84+
type: 'separator',
85+
},
86+
...Object.fromEntries(schemaAndOperationsRules.map(key => [key, ''])),
87+
_2: {
88+
title: 'Schema Rules',
89+
type: 'separator',
90+
},
91+
...Object.fromEntries(schemaRules.map(key => [key, ''])),
92+
_3: {
93+
title: 'Operations Rules',
94+
type: 'separator',
95+
},
96+
...Object.fromEntries(operationsRules.map(key => [key, ''])),
97+
},
98+
},
99+
play: {
100+
title: 'Playground',
101+
type: 'page',
102+
theme: {
103+
footer: false,
104+
},
105+
},
106+
};
File renamed without changes.

website/src/icons/astro.svg renamed to website/app/icons/astro.svg

Lines changed: 1 addition & 1 deletion
Loading

website/src/icons/gear.svg renamed to website/app/icons/gear.svg

Lines changed: 1 addition & 7 deletions
Loading
File renamed without changes.

0 commit comments

Comments
 (0)