Skip to content

Commit

Permalink
feat |> i18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
htoooth committed Dec 21, 2023
1 parent f84f489 commit 30f2da0
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 3 deletions.
58 changes: 55 additions & 3 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,62 @@ export default defineConfig({
title: "zepp-health/zml",
titleTemplate: ':title | zepp-health/zml',
description: "A mini development library for Zepp OS mini programs",
locales: {
root: {
label: 'English',
lang: 'en',
},
zh: {
label: '中文',
lang: 'zh', // optional, will be added as `lang` attribute on `html` tag
themeConfig: {
nav: [
{ text: 'Home', link: '/zh' },
{ text: 'Docs', link: './getting-started' },
{
text: '0.x',
items: [
{text: 'Releases', link: 'https://github.com/zepp-health/zml/release'},
],
},
],
sidebar: [
{
text: '文档',
items: [
{ text: '开始', link: './getting-started' },
{ text: 'API 参考', link: './api' }
]
},
{
text: '常见问题',
items: [
{ text: '已知问题', link: './known-issues' }
]
}
],
}
}
},
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
{ text: 'Docs', link: '/getting-started' }
{ text: 'Docs', link: '/getting-started' },
{
text: '0.x',
items: [
{text: 'Releases', link: 'https://github.com/zepp-health/zml/release'},
],
},
],
lastUpdated: {
text: 'Updated at',
formatOptions: {
dateStyle: 'short',
timeStyle: 'short'
}
},

sidebar: [
{
Expand All @@ -25,7 +75,7 @@ export default defineConfig({
{
text: 'FAQ',
items: [
{ text: 'Known Issues', link: './known-issues' }
{ text: 'Known Issues', link: '/known-issues' }
]
}
],
Expand All @@ -35,9 +85,11 @@ export default defineConfig({
],

editLink: {
pattern: 'https://github.com/google/zx/blob/gh-pages/:path',
pattern: 'https://github.com/zepp-health/zml/tree/main/docs/:path',
},

externalLinkIcon: true,

search: {
provider: 'local',
},
Expand Down
15 changes: 15 additions & 0 deletions docs/.vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import DefaultTheme from 'vitepress/theme'
import { useData, inBrowser } from 'vitepress'
import { watchEffect } from 'vue'

export default {
extends: DefaultTheme,
setup() {
const { lang } = useData()
watchEffect(() => {
if (inBrowser) {
document.cookie = `nf_lang=${lang.value}; expires=Mon, 1 Jan 2024 00:00:00 UTC; path=/`
}
})
}
}
49 changes: 49 additions & 0 deletions docs/zh/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
outline: deep
---

# Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:

```md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>
```

<script setup>
import { useData } from 'vitepress'

const { site, theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

## More

Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
85 changes: 85 additions & 0 deletions docs/zh/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Markdown Extension Examples

This page demonstrates some of the built-in markdown extensions provided by VitePress.

## Syntax Highlighting

VitePress provides Syntax Highlighting powered by [Shikiji](https://github.com/antfu/shikiji), with additional features like line-highlighting:

**Input**

````md
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
````

**Output**

```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```

## Custom Containers

**Input**

```md
::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::
```

**Output**

::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::

## More

Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
21 changes: 21 additions & 0 deletions docs/zh/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home

hero:
name: "ZML"
text: "A mini development library for Zepp OS mini programs"
actions:
- theme: brand
text: Documents
link: /zh/getting-started

features:
- title: Simple
details: Write your application in one line
- title: Powerful
details: Interact with Zepp OS API
- title: Batteries included
details: Everything you need, right out of the box.
---

Empty file added docs/zh/known-issues.md
Empty file.

0 comments on commit 30f2da0

Please sign in to comment.