feat(docs): document website enhancement (#3580)

- Add language jump support
- Fix ifBuild.sh bug on posix platform
This commit is contained in:
jeremywu 2021-09-23 11:08:19 +08:00 committed by GitHub
parent 139e79b29d
commit 7fa9afaa43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 4 deletions

2
docs/.gitignore vendored
View File

@ -1,5 +1,3 @@
.vitepress/*.js
.vitepress/i18n/*
temp
zh-CN

View File

@ -59,6 +59,22 @@ module.exports = {
href: '//unpkg.com/nprogress@0.2.0/nprogress.css',
},
],
[
'script',
{},
`;(() => {
window.supportedLangs = ${JSON.stringify(languages)}
})()`,
],
[
'script',
{},
require('fs').readFileSync(
require('path').resolve(__dirname, './lang.js'),
'utf-8'
),
],
features.theme
? [

15
docs/.vitepress/lang.js Normal file
View File

@ -0,0 +1,15 @@
;(() => {
const supportedLangs = window.supportedLangs
const userPreferredLang =
localStorage.getItem('preferred_lang') || navigator.language
if (
supportedLangs.includes(userPreferredLang) &&
!location.pathname.startsWith(`/${userPreferredLang}`)
) {
location.pathname = [`/${userPreferredLang}`]
.concat(location.pathname.split('/').slice(2))
.join('/')
}
})()

View File

@ -1,5 +1,5 @@
#!/bin/sh
if [ ! -d \"dist/element-plus\" ]; then
sh scripts/build.sh;
if [ ! -d "dist/element-plus" ]; then
sh scripts/build.sh
fi