11import snippetPlugin from "markdown-it-vuepress-code-snippet-enhanced" ;
2- import * as fs from "node:fs" ;
32import * as path from "node:path" ;
43import * as process from "node:process" ;
54import { tabsMarkdownPlugin } from "vitepress-plugin-tabs" ;
65import defineVersionedConfig from "vitepress-versioning-plugin" ;
7-
8- import { Fabric } from "../types" ;
6+ import latestVersionPlugin from "../plugins/latestVersion" ;
7+ import { Fabric } from "../types.d " ;
98import { getLocales } from "./i18n" ;
109import { transformHead , transformItems } from "./transform" ;
1110
@@ -26,14 +25,7 @@ const hostname =
2625 ? "http://fabric-docs.localhost:4173/"
2726 : env === "dev"
2827 ? "http://fabric-docs.localhost:5173/"
29- : process . env . DEPLOY_PRIME_URL ! ;
30-
31- const latestVersion = fs
32- . readFileSync (
33- path . resolve ( import . meta. dirname , ".." , ".." , "reference" , "latest" , "build.gradle" ) ,
34- "utf-8"
35- )
36- . match ( / d e f m i n e c r a f t V e r s i o n = " ( [ ^ " ] + ) " / ) ! [ 1 ] ;
28+ : `${ process . env . DEPLOY_PRIME_URL ! } /` ;
3729
3830// https://vitepress.dev/reference/site-config
3931// https://www.npmjs.com/package/vitepress-versioning-plugin
@@ -78,15 +70,16 @@ export default defineVersionedConfig(
7870 image : { lazyLoading : true } ,
7971 languageAlias : { gradle : "groovy" } ,
8072 languages : [
81- async ( ) =>
82- await import ( "syntax-mcfunction/mcfunction.tmLanguage.json" , {
83- with : { type : "json" } ,
84- } ) . then ( ( lang ) => ( { ...( lang . default as any ) , name : "mcfunction" } ) ) ,
85- async ( ) =>
86- await import ( "syntax-java-bytecode/java-bytecode.tmLanguage.json" , {
87- with : { type : "json" } ,
88- } ) . then ( ( lang ) => ( { ...( lang . default as any ) , name : "bytecode" } ) ) ,
89- ] ,
73+ [ "mcfunction" , "syntax-mcfunction/mcfunction.tmLanguage.json" ] ,
74+ [ "bytecode" , "syntax-java-bytecode/java-bytecode.tmLanguage.json" ] ,
75+ ] . map (
76+ ( [ name , path ] ) =>
77+ async ( ) =>
78+ await import ( path , { with : { type : "json" } } ) . then ( ( lang ) => ( {
79+ ...lang . default ,
80+ name,
81+ } ) )
82+ ) ,
9083 lineNumbers : true ,
9184 shikiSetup : async ( shiki ) => {
9285 await shiki . loadTheme ( "github-light" , "github-dark" ) ;
@@ -125,7 +118,6 @@ export default defineVersionedConfig(
125118
126119 // Versioning plugin configuration.
127120 versioning : {
128- latestVersion,
129121 rewrites : { localePrefix : "translated" } ,
130122 sidebars : {
131123 sidebarContentProcessor : ( s ) =>
@@ -143,6 +135,10 @@ export default defineVersionedConfig(
143135 url . startsWith ( "/" ) ? `/${ version } ${ / ^ [ / ] .._ ..[ / ] / . test ( url ) ? url . slice ( 6 ) : url } ` : url ,
144136 } ,
145137 } ,
138+
139+ vite : {
140+ plugins : [ latestVersionPlugin ( ) ] ,
141+ } ,
146142 } ,
147143 path . resolve ( import . meta. dirname , ".." )
148144) ;
0 commit comments