Skip to content

Commit 36580b5

Browse files
committed
chore(docs): apply artalk locale from html lang
1 parent 9afa7ca commit 36580b5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

docs/docs/.vitepress/config/shared.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const shared = defineConfig({
4747
},
4848

4949
lastUpdated: true,
50-
cleanUrls: true,
50+
cleanUrls: false,
5151
metaChunk: true,
5252

5353
themeConfig: {

docs/docs/.vitepress/theme/Artalk.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ function initArtalk(conf: any) {
4747
},
4848
})
4949
50+
Artalk.use((ctx) => {
51+
ctx.on('mounted', () => {
52+
// TODO: Optimize the locale setting, which is overwritten by the remote server config
53+
const locale = document.documentElement.lang.includes('zh') ? 'zh-CN' : 'en'
54+
if (locale !== ctx.getConf().locale) ctx.updateConf({ locale })
55+
})
56+
})
57+
5058
artalk = Artalk.init({
5159
el: el.value,
5260
emoticons: '/assets/emoticons/default.json',
@@ -58,7 +66,7 @@ function initArtalk(conf: any) {
5866
5967
function getConfByPage() {
6068
return {
61-
pageKey: 'https://artalk.js.org' + router.route.path,
69+
pageKey: `https://artalk.js.org/${router.route.path.replace(/^\//, '').replace(/\.html$/, '')}.html`,
6270
pageTitle: page.value.title,
6371
server: 'https://artalk.qwqaq.com',
6472
site: 'ArtalkDocs',

0 commit comments

Comments
 (0)