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
+1916
-1898
File diff suppressed because it is too large
Load Diff
+22
-19
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user