Generate versions.json at build time
This commit is contained in:
5 files changed
+38
-12
No files matched your search
@@ -78,7 +78,8 @@ const config: Config = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'docusaurus-plugin-sass'
|
'docusaurus-plugin-sass',
|
||||||
|
'./src/plugins/create-versions-json.ts'
|
||||||
],
|
],
|
||||||
themes: ["docusaurus-theme-openapi-docs"],
|
themes: ["docusaurus-theme-openapi-docs"],
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import versions from '../data/versions.json';
|
import versions from '../data/versions.json';
|
||||||
|
|
||||||
export const Versions = ({ platform }) => {
|
export const Versions = ({ platform }) => {
|
||||||
return versions[platform]
|
return versions[platform].supported
|
||||||
};
|
};
|
||||||
+10
-2
@@ -1,4 +1,12 @@
|
|||||||
{
|
{
|
||||||
"bedrock": "1.20.80-1.21.2",
|
"bedrock": {
|
||||||
"java": "1.21"
|
"supported": "1.20.80-1.21.2",
|
||||||
|
"latest": {
|
||||||
|
"id": 686,
|
||||||
|
"name": "1.21.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"java": {
|
||||||
|
"supported": "1.21"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"bedrock": {
|
|
||||||
"protocol": {
|
|
||||||
"id": 686,
|
|
||||||
"name": "1.21.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user