feat: added graphql warning at the top (#117)

This commit is contained in:
Kyrch
2025-07-27 19:27:53 -03:00
committed by GitHub
parent 578f00cdaf
commit fe9a3017e5
6 changed files with 1985 additions and 1917 deletions
+1
View File
@@ -0,0 +1 @@
**/*.md
+4
View File
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"printWidth": 120
}
+4
View File
@@ -1,4 +1,5 @@
import 'dotenv/config';
import graphqlWarnPlugin from './theme/graphql-warn-plugin';
const referenceSidebarItems = [
{
@@ -511,6 +512,9 @@ const referenceSidebarItems = [
];
export default {
vite: {
plugins: [graphqlWarnPlugin()],
},
base: process.env.VITEPRESS_BASE,
lang: 'en-US',
lastUpdated: true,
@@ -0,0 +1,38 @@
import path from "path";
export default function graphqlWarnPlugin() {
return {
name: "graphql-warn-plugin",
enforce: "pre",
transform(code, id) {
if (!id.endsWith(".md")) return;
const relativePath = path.relative(process.cwd(), id);
if (!relativePath.includes("graphql")) return;
const warningBlock = [
"::: warning",
"⚠️ The GraphQL API is experimental and subject to change without notice.",
":::",
"",
].join("\n");
if (code.startsWith("---")) {
const endOfFrontmatter = code.indexOf("---", 3);
if (endOfFrontmatter !== -1) {
const before = code.slice(0, endOfFrontmatter + 3);
const after = code.slice(endOfFrontmatter + 3);
return {
code: `${before}\n\n${warningBlock}${after}`,
map: null,
};
}
}
return {
code: warningBlock + code,
map: null,
};
},
};
}
+1916 -1898
View File
File diff suppressed because it is too large Load Diff
+22 -19
View File
@@ -1,21 +1,24 @@
{
"name": "animethemes-api-docs",
"version": "4.0.0",
"description": "AnimeThemes.moe GraphQL API Documentation",
"main": "index.js",
"authors": {
"name": "AnimeThemes",
"email": "admin@animethemes.moe"
},
"repository": "https://github.com/AnimeThemes/animethemes-api-docs",
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"license": "MIT",
"dependencies": {
"dotenv": "^16.1.4",
"vitepress": "^2.0.0-alpha.9"
}
"name": "animethemes-api-docs",
"version": "4.0.0",
"description": "AnimeThemes.moe GraphQL API Documentation",
"main": "index.js",
"authors": {
"name": "AnimeThemes",
"email": "admin@animethemes.moe"
},
"repository": "https://github.com/AnimeThemes/animethemes-api-docs",
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"license": "MIT",
"dependencies": {
"dotenv": "^16.1.4",
"vitepress": "^2.0.0-alpha.9"
},
"devDependencies": {
"prettier": "3.6.2"
}
}