Generate versions.json at build time

This commit is contained in:
rtm516 committed 2024-07-27 15:28:39 +01:00
1 parent 932dda7edd
commit 352260a7dc
5 files changed
+38 -12

No files matched your search

+2 -1
View File
@@ -78,7 +78,8 @@ const config: Config = {
},
},
],
'docusaurus-plugin-sass'
'docusaurus-plugin-sass',
'./src/plugins/create-versions-json.ts'
],
themes: ["docusaurus-theme-openapi-docs"],
+1 -1
View File
@@ -1,5 +1,5 @@
import versions from '../data/versions.json';
export const Versions = ({ platform }) => {
return versions[platform]
return versions[platform].supported
};
+10 -2
View File
@@ -1,4 +1,12 @@
{
"bedrock": "1.20.80-1.21.2",
"java": "1.21"
"bedrock": {
"supported": "1.20.80-1.21.2",
"latest": {
"id": 686,
"name": "1.21.2"
}
},
"java": {
"supported": "1.21"
}
}
+25
View File
@@ -0,0 +1,25 @@
import fs from 'fs';
import path from 'path';
import { LoadContext, Plugin, PluginOptions } from '@docusaurus/types';
import logger from '@docusaurus/logger';
import versions from '../data/versions.json';
const createVersionsJsonPlugin = (context: LoadContext, options: PluginOptions): Plugin => {
return {
name: 'docusaurus-plugin-create-versions-json',
async postBuild({ outDir, routes, plugins }) {
const versionsFilePath = path.join(outDir, 'versions.json');
fs.writeFileSync(versionsFilePath, JSON.stringify({
"bedrock": {
"protocol": versions.bedrock.latest
}
}, null, 2), 'utf-8');
logger.success(`Created versions.json file at ${versionsFilePath}`);
},
};
};
export default createVersionsJsonPlugin;
-8
View File
@@ -1,8 +0,0 @@
{
"bedrock": {
"protocol": {
"id": 686,
"name": "1.21.2"
}
}
}