Skip to content

Commit 0f7958f

Browse files
committed
docs: add language options for homepage
1 parent 90b8fb9 commit 0f7958f

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

docs/.vuepress/theme/components/Intro.vue

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<template>
22
<div class="intro-container">
33
<p v-text="$description || 'Welcome to your VuePress site'"></p>
4+
<p v-if="languages.length">
5+
<template v-for="(lang, $index) in languages">
6+
<router-link :to="lang.path" v-text="lang.name"></router-link><span v-if="$index < languages.length - 1"> | </span>
7+
</template>
8+
</p>
49
<router-link
510
class="button button-large button-basic"
611
v-if="data.actionText && data.actionLink"
@@ -47,6 +52,22 @@ export default {
4752
? link
4853
: `https://github.com/${link}`;
4954
},
55+
languages() {
56+
const locales = this.$themeConfig.$locales || this.$site.locales || [];
57+
const localeMapping = {
58+
'/': 'EN',
59+
'en-US': 'EN',
60+
'/zh/': '中文',
61+
'zh-CN': '中文',
62+
};
63+
64+
return Object.keys(locales).map((path) => {
65+
return {
66+
name: localeMapping[locales[path].lang] || localeMapping[path] || path.replace(/\//g).toUpperCase(),
67+
path: path,
68+
};
69+
});
70+
},
5071
},
5172
};
5273
</script>
@@ -66,12 +87,22 @@ export default {
6687
width auto
6788
6889
> p
69-
margin 0 0 40px
90+
margin 0
7091
color $c-basic-light
7192
7293
@media (max-width $mq-mobile)
7394
line-height 1.28
7495
96+
+ p
97+
margin-bottom 40px
98+
99+
a:not(.router-link-exact-active)
100+
font-weight 400
101+
color #aaa
102+
103+
span
104+
color #ddd
105+
75106
.button
76107
white-space nowrap
77108
@@ -88,7 +119,7 @@ export default {
88119
.feat-list
89120
list-style none
90121
display flex
91-
margin-top 60px
122+
margin-top 50px
92123
padding 0
93124
94125
@media (max-width $mq-mobile)

docs/.vuepress/theme/layouts/Layout.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ body
157157
#logo
158158
position absolute
159159
z-index 21
160-
top 100px
160+
top 90px
161161
left $s-home-divide-ratio
162162
display inline-block
163163
margin-left 216px + $s-home-middle-gap
@@ -181,7 +181,7 @@ body
181181
+ h1
182182
position absolute
183183
z-index 21
184-
top 280px
184+
top 260px
185185
left $s-home-divide-ratio
186186
margin-left 164px + $s-home-middle-gap
187187
color $c-basic
@@ -207,7 +207,7 @@ body
207207
.intro-container
208208
position absolute
209209
z-index 1
210-
top 346px
210+
top 316px
211211
left $s-home-divide-ratio
212212
margin-left $s-home-middle-gap
213213
transition all 0.3s

0 commit comments

Comments
 (0)