mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-18 10:59:10 +08:00
perf: improve jump link for home page (#3551)
This commit is contained in:
parent
a887a9632e
commit
b8cf646226
@ -1,4 +1,6 @@
|
||||
/* eslint-disable */
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const sidebars = require('./sidebars')
|
||||
const nav = require('./nav')
|
||||
const mdPlugin = require('./plugins')
|
||||
@ -31,6 +33,8 @@ const buildTransformers = () => {
|
||||
}
|
||||
console.log(process.env.DOC_ENV)
|
||||
|
||||
const languages = fs.readdirSync(path.resolve(__dirname, './crowdin'))
|
||||
|
||||
module.exports = {
|
||||
title: 'ElementPlus',
|
||||
head: [
|
||||
@ -84,6 +88,7 @@ module.exports = {
|
||||
appId: '7DCTSU0WBW',
|
||||
},
|
||||
features,
|
||||
langs: languages,
|
||||
},
|
||||
|
||||
markdown: {
|
||||
|
@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { useData } from 'vitepress'
|
||||
import { useData, inBrowser } from 'vitepress'
|
||||
import { computed } from 'vue'
|
||||
|
||||
import VPNavbarSearch from './navbar/vp-search.vue'
|
||||
import VPNavbarMenu from './navbar/vp-menu.vue'
|
||||
@ -17,13 +18,22 @@ defineEmits(['toggle'])
|
||||
const themeEnabled = useFeatureFlag('theme')
|
||||
|
||||
const { theme } = useData()
|
||||
|
||||
const currentLink = computed(() => {
|
||||
if (!inBrowser) return '/'
|
||||
const existLangIndex = theme.value.langs.findIndex((lang) =>
|
||||
window?.location?.pathname.startsWith(`/${lang}`)
|
||||
)
|
||||
|
||||
return existLangIndex === -1 ? '/' : `/${theme.value.langs[existLangIndex]}/`
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="navbar-wrapper">
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<a href="/">
|
||||
<a :href="currentLink">
|
||||
<img
|
||||
class="logo"
|
||||
src="/images/element-plus-logo.svg"
|
||||
|
Loading…
Reference in New Issue
Block a user