Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Language Support + Complete Chinese Translation #48

Merged
merged 56 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0494566
dropdown - init
ulivz Apr 14, 2018
121e6ca
add nav link component to distinguish internal and external link
ulivz Apr 14, 2018
3ddca36
enhance the active state of dropdown link
ulivz Apr 14, 2018
72be30c
beautify font weight for dropdown link and clean code
ulivz Apr 14, 2018
4bccf3a
clean code
ulivz Apr 14, 2018
5ac3c2a
update doc
ulivz Apr 14, 2018
dbb7a08
update README
ulivz Apr 14, 2018
50689ea
address comments
ulivz Apr 14, 2018
6de2efa
fix jumpy link
ulivz Apr 14, 2018
a760d59
i18n - init
ulivz Apr 14, 2018
7eb2563
address comments
ulivz Apr 14, 2018
94c2236
use exact match mode for route link
ulivz Apr 14, 2018
0c53333
Merge branch 'dropdown' into i18n
ulivz Apr 14, 2018
e30c580
support configurable i18n
ulivz Apr 14, 2018
c6188b9
translate README of guide
ulivz Apr 14, 2018
d414794
tweaks translations and update the actionLink
ulivz Apr 14, 2018
8a131a9
add sidebar config for zh
ulivz Apr 14, 2018
711e772
translate basic-config and getting-started
ulivz Apr 14, 2018
34d8d78
refactor code
ulivz Apr 14, 2018
6c9e1a4
implement nested links in dropdown
ulivz Apr 14, 2018
5ca1d02
clean dropdown type
ulivz Apr 14, 2018
7c6d462
fix cursor status
ulivz Apr 14, 2018
96c30c5
chore: tweaks
ulivz Apr 15, 2018
3397dc2
Merge branch 'master' into dropdown
ulivz Apr 15, 2018
f8e10cf
Merge branch 'dropdown' into i18n
ulivz Apr 15, 2018
7ea050e
zh - translate guide/assets
ulivz Apr 15, 2018
00e6430
zh - translate guide/markdown
ulivz Apr 15, 2018
dbf07fb
zh - translate guide/using-vue
ulivz Apr 15, 2018
9506184
zh - translate guide/custom-themes
ulivz Apr 15, 2018
8a900a4
zh - translate guide/deploy
ulivz Apr 15, 2018
79eff60
zh - translate /config/
ulivz Apr 15, 2018
01ab22e
zh - translate /default-theme-config/
ulivz Apr 15, 2018
08d80b1
correct some mistakes in Chinses translation.
ulivz Apr 15, 2018
6ebbd88
refactor docs
ulivz Apr 15, 2018
eee3ac7
style: tweaks style of navbar to fully follow sidebar at mobile side.
ulivz Apr 15, 2018
a811af5
refactor Chinese translations
ulivz Apr 15, 2018
5030421
Merge branch 'master' into dropdown
ulivz Apr 16, 2018
96a6cc6
refactor: address comments and clean duplicate code due to merging.
ulivz Apr 16, 2018
7f440d0
style: use more exact class selector, and clean old element selector …
ulivz Apr 16, 2018
069d677
Merge branch 'dropdown' into multiple-language-support
ulivz Apr 16, 2018
645c22d
chore: fix merge conflict
ulivz Apr 16, 2018
028669b
Merge branch 'master' into multiple-language-support
ulivz Apr 16, 2018
2d76589
support multiple langs for title and homepage link
ulivz Apr 17, 2018
ddf759f
handle for lang and description - dev & build
ulivz Apr 17, 2018
c779dde
handle description meta at dev mode
ulivz Apr 17, 2018
5c7190d
Merge branch 'master' into multiple-language-support
ulivz Apr 17, 2018
e64fd82
translate latest updated doc
ulivz Apr 17, 2018
4e769a6
Complete proofreading
ulivz Apr 17, 2018
beac14f
feat: Auto-generated language dropdown if user configured langs
ulivz Apr 17, 2018
b8dc3f0
feat: Try to stay on the current page When user switch the language
ulivz Apr 17, 2018
f2fb2d9
chore: clean code
ulivz Apr 17, 2018
4f1b004
chore: clean code
ulivz Apr 17, 2018
c5a2079
fix: typo
ulivz Apr 17, 2018
961cf2d
feat: support override description meta with yaml front matter
ulivz Apr 18, 2018
1c31f82
replace those IE11-incompatible API with ES5
ulivz Apr 18, 2018
b794126
docs: document config.host for zh-CN
ulivz Apr 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add nav link component to distinguish internal and external link
  • Loading branch information
ulivz committed Apr 14, 2018
commit 121e6cabec46eea1f138c849e0c0cb743d490aa3
13 changes: 4 additions & 9 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@ module.exports = {
link: '/default-theme-config/'
},
{
text: 'Dropdown Test',
text: 'Links',
type: 'dropdown',
items: [
{
text: 'item1',
link: '/dropdown-test/'
},
{
text: 'item1',
link: '/dropdown-test/'
text: 'Vue',
link: 'https://vuejs.org/',
}
],
link: '/dropdown-test/'
},
}
],
sidebar: {
'/guide/': [
Expand Down
33 changes: 33 additions & 0 deletions lib/default-theme/NavLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<router-link
class="router-link"
:to="item.link"
v-if="!isExternal(item.link)">
{{ item.text }}
</router-link>
<a
v-else
:href="item.link"
target="_blank"
class="router-link">
{{ item.text }}
</a>
</template>

<script>
import { isExternal } from './util'
export default {
props: {
item: {
required: true
}
},
mixins: [
{
methods: {
isExternal
}
}
]
}
</script>
103 changes: 55 additions & 48 deletions lib/default-theme/NavLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
<!-- user links -->
<div class="nav-item" v-for="item in userLinks" :key="item.link">
<div
v-if="item.type === 'dropdown'"
class="nav-dropdown-wrapper">
v-if="item.type === 'dropdown'"
class="nav-dropdown-wrapper">
<span>{{ item.text }}</span>
<span class="arrow"></span>
<ul class="nav-dropdown">
<li v-for="subItem in item.items">
<router-link
:to="subItem.link">
{{ subItem.text }}
</router-link>
<li
v-for="subItem in item.items"
:key="subItem.link">
<nav-link :item="subItem"></nav-link>
</li>
</ul>
</div>
<router-link
v-else
:to="item.link">
{{ item.text }}
</router-link>
<nav-link v-else :item="item"></nav-link>
</div>
<!-- github link -->
<a v-if="githubLink"
Expand All @@ -35,16 +31,17 @@

<script>
import OutboundLink from './OutboundLink.vue'
import NavLink from './NavLink.vue'
import { isActive, ensureExt } from './util'

export default {
components: { OutboundLink },
components: { OutboundLink, NavLink },
computed: {
userLinks () {
return (this.$site.themeConfig.nav || []).map(({ text, link, type, items }) => ({
text,
type,
link: ensureExt(link),
link: link ? ensureExt(link) : void 0,
items: (items || []).map(({ text, link }) => ({ text, link: ensureExt(link) }))
}))
},
Expand Down Expand Up @@ -73,8 +70,6 @@ export default {
color inherit
&:hover, &.router-link-active
color $accentColor
.github-link
margin-left 1.5rem
.nav-item
position relative
display inline-block
Expand All @@ -84,46 +79,58 @@ export default {
.nav-dropdown-wrapper
cursor pointer
padding-right 15px
&:after
content: ''
position absolute
right: 0px
top: calc(50% - 2px)
display block
border-left: 4px solid transparent
border-right: 4px solid transparent
border-top: 5px solid #ccc
.arrow
display: inline-block;
vertical-align: middle;
margin-top: -1px;
margin-left: 6px;
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 5px solid #ccc;
&:hover
.nav-dropdown
display: block
.nav-dropdown
display: none
box-sizing: border-box;
max-height: calc(100vh - 2.7rem)
overflow-y: auto
position: absolute
top: 100%
right: 0
background-color: #fff
padding: 10px 0
border: 1px solid #ddd
border-bottom-color: #ccc
text-align: left
border-radius: 0.25rem
white-space: nowrap
margin 0
& > li
color inherit
line-height 1.7rem
padding: 0 1.5rem 0 1.25rem;
padding: 0 1.5rem 0 1.25rem
&:hover
color $accentColor
.github-link
margin-left 1.5rem

@media (max-width: $MQMobile)
.nav-links a
margin-left 0
.nav-links
.nav-item
display block
margin-left 0
.github-link
margin-left 0

@media (min-width: $MQMobile)
.nav-links a
&:hover, &.router-link-active
color $textColor
margin-bottom -2px
border-bottom 2px solid lighten($accentColor, 5%)
.nav-links
a
&:hover, &.router-link-active
color $textColor
margin-bottom -2px
border-bottom 2px solid lighten($accentColor, 5%)
.nav-dropdown
display: none
box-sizing: border-box;
max-height: calc(100vh - 2.7rem)
overflow-y: auto
position: absolute
top: 100%
right: 0
background-color: #fff
padding: 10px 0
border: 1px solid #ddd
border-bottom-color: #ccc
text-align: left
border-radius: 0.25rem
white-space: nowrap
margin 0
</style>
5 changes: 4 additions & 1 deletion lib/default-theme/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ function resolveOpenGroupIndex (route, items) {
display none
border-bottom 1px solid $borderColor
padding 0.5rem 0 0.75rem 0
a
.nav-item, .github-link, .nav-dropdown > li
display block
line-height 1.25rem
font-weight 600
font-size 1.1em
padding 0.5rem 0 0.5rem 1.5rem
.nav-item .nav-dropdown-wrapper .nav-dropdown > li
padding-top 10px
.sidebar-links
margin-top 1.5rem

Expand Down
6 changes: 5 additions & 1 deletion lib/default-theme/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ export function getHash (path) {
}
}

export function isExternal (path) {
return outboundRE.test(path)
}

export function ensureExt (path) {
if (outboundRE.test(path)) {
if (isExternal(path)) {
return path
}
const hashMatch = path.match(hashRE)
Expand Down