Skip to content

Commit

Permalink
docs: add helper docs (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope authored Feb 3, 2024
1 parent 1900257 commit df2751c
Show file tree
Hide file tree
Showing 18 changed files with 1,470 additions and 9 deletions.
13 changes: 13 additions & 0 deletions docs/.vuepress/configs/navbar/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const navbarEn: NavbarConfig = [
text: 'Default Theme',
link: '/themes/default/',
},
{
text: 'Hope Theme',
link: 'https://theme-hope.vuejs.press',
},
],
},
{
Expand Down Expand Up @@ -62,4 +66,13 @@ export const navbarEn: NavbarConfig = [
},
],
},
{
text: 'Tools',
children: [
{
text: 'helper',
link: '/tools/helper/',
},
],
},
]
13 changes: 13 additions & 0 deletions docs/.vuepress/configs/navbar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const navbarZh: NavbarConfig = [
text: '默认主题',
link: '/zh/themes/default/',
},
{
text: 'Hope 主题',
link: 'https://theme-hope.vuejs.press/zh/',
},
],
},
{
Expand Down Expand Up @@ -66,4 +70,13 @@ export const navbarZh: NavbarConfig = [
},
],
},
{
text: '工具',
children: [
{
text: 'helper',
link: '/zh/tools/helper/',
},
],
},
]
14 changes: 13 additions & 1 deletion docs/.vuepress/configs/sidebar/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export const sidebarEn: SidebarConfig = {
'/themes/': [
{
text: 'Default Theme',
link: '/themes/default/',
children: [
'/themes/default/',
'/themes/default/config',
'/themes/default/plugin',
'/themes/default/locale',
Expand All @@ -93,4 +93,16 @@ export const sidebarEn: SidebarConfig = {
],
},
],
'/tools/': [
{
text: '@vuepress/helper',
link: '/tools/helper/',
children: [
'/tools/helper/node/bundler',
'/tools/helper/node/page',
'/tools/helper/client',
'/tools/helper/shared',
],
},
],
}
14 changes: 13 additions & 1 deletion docs/.vuepress/configs/sidebar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export const sidebarZh: SidebarConfig = {
'/zh/themes/': [
{
text: '默认主题',
link: '/zh/themes/default/',
children: [
'/zh/themes/default/',
'/zh/themes/default/config',
'/zh/themes/default/plugin',
'/zh/themes/default/locale',
Expand All @@ -98,4 +98,16 @@ export const sidebarZh: SidebarConfig = {
],
},
],
'/zh/tools/': [
{
text: '@vuepress/helper',
link: '/zh/tools/helper/',
children: [
'/zh/tools/helper/node/bundler',
'/zh/tools/helper/node/page',
'/zh/tools/helper/client',
'/zh/tools/helper/shared',
],
},
],
}
4 changes: 2 additions & 2 deletions docs/themes/default/locale.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ export default {
}
```

### navbarLabel
## navbarLabel

- Type: `null | string`

- Details:

`aria-label` value for main navigation in navbar.

### pageNavbarLabel
## pageNavbarLabel

- Type: `null | string`

Expand Down
13 changes: 13 additions & 0 deletions docs/tools/helper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @vuepress/helper

<NpmBadge package="@vuepress/helper" />

This package is a helper utility for VuePress developers.

- `@vuepress/helper`: Node.js side helper utilities.

- [Bundler Related](node/bundler.md)
- [Page Related](node/page.md)

- [`@vuepress/helper/client`](client.md): Client side helper utilities.
- [`@vuepress/helper/shared`](shared.md): Utilities that are both available at Node.js side or Client.
59 changes: 59 additions & 0 deletions docs/tools/helper/client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Client Related

## Composables APIs

### hasGlobalComponent

Check whether a component is registered globally.

::: tip

1. Local import of the component does not affect the result.
1. When calling outside `setup` scope, you need to pass the `app` instance as the second parameter.

:::

```ts
export const hasGlobalComponent: (name: string, app?: App) => boolean
```
::: details Example
```ts
// if you globally register `<my-component>`
hasGlobalComponent('MyComponent') // true
hasGlobalComponent('my-component') // true

hasGlobalComponent('MyComponent2') // false
```

:::

### useLocaleConfig

Get current locale config from locales settings.

```ts
export const useLocaleConfig: <T extends LocaleData>(
localesConfig: RequiredLocaleConfig<T>,
) => ComputedRef<T>
```
::: details Example
```ts
const localesCOnfig = {
'/': 'Title',
'/zh/': '标题',
}

const locale = useLocaleConfig(localesConfig)

// under `/page`
locale.value // 'Title'

// under `/zh/page`
locale.value // '标题'
```

:::
Loading

0 comments on commit df2751c

Please sign in to comment.