aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/docs/.docs/content/2.api/2.composables.md
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-19 17:30:39 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-19 17:30:39 +0800
commit3adc965dd09490b7efa1cce9f09b0a3b30970277 (patch)
treef813abb07d7b003984aa74e3154752b6ffc3ccd5 /docs/.docs/content/2.api/2.composables.md
parentc7c9ca6f0c8eddf6d34cd40779f3b2d9463f3a46 (diff)
downloadHydroRoll-3adc965dd09490b7efa1cce9f09b0a3b30970277.tar.gz
HydroRoll-3adc965dd09490b7efa1cce9f09b0a3b30970277.zip
✨优化文档
Diffstat (limited to 'docs/.docs/content/2.api/2.composables.md')
-rw-r--r--docs/.docs/content/2.api/2.composables.md88
1 files changed, 88 insertions, 0 deletions
diff --git a/docs/.docs/content/2.api/2.composables.md b/docs/.docs/content/2.api/2.composables.md
new file mode 100644
index 0000000..4c0bea2
--- /dev/null
+++ b/docs/.docs/content/2.api/2.composables.md
@@ -0,0 +1,88 @@
+# Composables
+
+Discover the Docus composables to use in your custom Vue components and pages.
+
+## `useDocus()`
+
+`useDocus()`{lang=ts} gives access to docus runtime config, all default values and your custom config from `app.config.ts`
+
+- `config` refers to the merged config of the current page.
+
+`main`, `header`, `aside`, `footer` and `titleTemplate` can be set from `_dir.yml` and any `page.md` file.
+
+The configs in `app.config` file will be used as defaults.
+
+```vue
+<script setup>
+const { config } = useDocus()
+</script>
+
+<template>
+ <div>
+ <h1>{{ config.title }}</h1>
+ <p>{{ config.description }}</p>
+ </div>
+</template>
+```
+
+- `tree` refers to the current navigation tree that is displayed in the `aside` component.
+
+```vue
+<script setup>
+const { tree } = useDocus()
+</script>
+
+<template>
+ <DocsAsideTree :links="tree" />
+</template>
+```
+
+::source-link
+---
+source: "composables/useDocus.ts"
+---
+::
+
+## `useMenu()`
+
+`useMenu()` gives access to `$menu` plugin controlling mobile navigation globally.
+
+```ts
+const {
+ // Is menu visible
+ visible,
+ // Close menu function
+ close,
+ // Open menu function
+ open,
+ // Toggle menu function
+ toggle
+} = useMenu()
+```
+
+::source-link
+---
+source: "composables/useMenu.ts"
+---
+::
+
+## `useScrollspy()`
+
+`useScrollspy()` is used in `docs` layout to make the ToC display the currently visible headings.
+
+```ts
+const {
+ // Headings on the page
+ visibleHeadings,
+ // Active headings (for the current page)
+ activeHeadings,
+ // Update headings (an array of DOM nodes)
+ updateHeadings
+} = useScrollspy()
+```
+
+::source-link
+---
+source: "composables/useScrollspy.ts"
+---
+::