mirror of
https://github.com/AnimeThemes/animethemes-api-docs.git
synced 2026-07-11 01:34:06 +02:00
feat: added graphql warning at the top (#117)
(cherry picked from commit fe9a3017e5)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
**/*.md
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"printWidth": 120
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
Generated
+18
@@ -11,6 +11,9 @@
|
||||
"dependencies": {
|
||||
"dotenv": "^16.1.4",
|
||||
"vitepress": "^2.0.0-alpha.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "3.6.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/helper-string-parser": {
|
||||
@@ -1509,6 +1512,21 @@
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
|
||||
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/property-information": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz",
|
||||
|
||||
@@ -17,5 +17,8 @@
|
||||
"dependencies": {
|
||||
"dotenv": "^16.1.4",
|
||||
"vitepress": "^2.0.0-alpha.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "3.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user