site: derive document.title by path when doing init

This commit is contained in:
07akioni 2021-06-06 00:36:23 +08:00
parent 595cc449c0
commit dae5913596

View File

@ -15,6 +15,12 @@
</head>
<body>
<script>
const path = window.location.pathname
const pathLocale = path.startsWith('/en-US')
? 'en-US'
: path.startsWith('/zh-CN')
? 'zh-CN'
: undefined
function deriveTitleFromLocale(locale = navigator.language) {
if (locale === 'zh-CN') {
document.title = 'Naive UI: 一个 Vue 3 组件库'
@ -22,7 +28,7 @@
document.title = 'Naive UI: A Vue 3 Component Library'
}
}
deriveTitleFromLocale()
deriveTitleFromLocale(pathLocale)
</script>
<div id="app"></div>
<script type="module" src="__INDEX__"></script>