Skip to content

Commit 56c855f

Browse files
committed
fix: autofill base again again again again again again again again
1 parent 546481d commit 56c855f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ jobs:
2020
BRANCH_NAME=$(echo $BRANCH | sed 's|origin/||')
2121
if [[ $BRANCH_NAME == ver/* ]]; then
2222
VER=$(echo $BRANCH_NAME | sed 's|build/ver/||')
23-
echo sed -i "s/BASE_INJECT_POINT/${VER}/g" ./docs/.vitepress/config.mts > replace.sh
24-
chmod +x replace.sh
25-
./replace.sh
26-
rm replace.sh
23+
echo ${VER} > VER
2724
fi
2825
2926
- name: Setup Node.js

docs/.vitepress/config.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {withI18n} from 'vitepress-i18n';
55
import {VitePressI18nOptions} from 'vitepress-i18n/dist/types';
66
import {VitePressSidebarOptions, withSidebar} from "vitepress-sidebar";
77
import {tabsPlugin} from "./theme/tabs/codesMarkdownPlugin";
8+
import fs from "fs";
89

910
const defaultLocale: string = 'en';
1011
const supportLocales: string[] = [defaultLocale, 'zhHans'];
@@ -31,7 +32,7 @@ const vitepressOptions: UserConfig = {
3132
rewrites: {
3233
'en/:rest*': ':rest*'
3334
},
34-
base: 'BASE_INJECT_POINT',
35+
base: getBase(),
3536
vite: {
3637
optimizeDeps: {
3738
exclude: [
@@ -139,4 +140,12 @@ const vitepressSidebarOptions = [
139140
})
140141
];
141142

143+
function getBase(): string {
144+
if (fs.existsSync("VER")) {
145+
return `/${fs.readFileSync("VER", 'utf8')}/`;
146+
} else {
147+
return '';
148+
}
149+
}
150+
142151
export default defineConfig(withSidebar(withI18n(vitepressOptions, vitePressI18nOptions), vitepressSidebarOptions))

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@nolebase/vitepress-plugin-enhanced-readabilities": "^2.10.0",
1414
"@types/markdown-it": "^14.1.2",
1515
"@types/markdown-it-container": "^2.0.10",
16+
"fs": "^0.0.1-security",
1617
"markdown-it": "^14.1.0",
1718
"markdown-it-container": "^4.0.0",
1819
"markdown-it-mathjax3": "^4.3.2",

0 commit comments

Comments
 (0)