feat: $lang and $localePath globals (#166) (#167)

close #166 

Co-authored-by: Kia King Ishii <kia.king.08@gmail.com>
pull/211/head
Matias Capeletto 4 years ago committed by GitHub
parent 417caf3c28
commit 481c4513d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,6 +64,14 @@ Reference of `$page.frontmatter`.
}
```
## $lang
The language of the current page. Default: `en-US`.
## $localePath
The locale path prefix for the current page. Default: `/`.
## $title
Value of the `<title>` label used for the current page.

@ -42,6 +42,25 @@ export function mixinGlobalComputed(
}
},
$lang: {
get() {
return siteByRoute.value.lang
}
},
$localePath: {
get() {
const { locales } = site.value
const { lang } = siteByRoute.value
const path = Object.keys(locales).find(
(lp) => locales[lp].lang === lang
)
return (locales && path) || '/'
}
},
$title: {
get() {
return page.value.title

Loading…
Cancel
Save