From 5a2dde162451f69533c813856c6ce3f7fbca5f32 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Tue, 20 Oct 2020 17:45:34 -0500 Subject: [PATCH] Update docs --- docs/configuration.md | 113 +++++++++++++++++++-- docs/index.html | 29 ++++-- docs/vue.md | 226 ++++++++++++++++++++++++++++++------------ 3 files changed, 289 insertions(+), 79 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 7a65553..54d6720 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -494,15 +494,15 @@ window.$docsify = { ``` ## crossOriginLinks -- type: `Array` -When `routerMode: 'history'`, you may face the cross-origin issues, See [#1379](https://github.com/docsifyjs/docsify/issues/1379). -In Markdown content, there is a simple way to solve it, see extends Markdown syntax `Cross-Origin link` in [helpers](helpers.md). +- type: `Array` + +When `routerMode: 'history'`, you may face the cross-origin issues, See [#1379](https://github.com/docsifyjs/docsify/issues/1379). +In Markdown content, there is a simple way to solve it, see extends Markdown syntax `Cross-Origin link` in [helpers](helpers.md). + ```js window.$docsify = { - crossOriginLinks:[ - "https://example.com/cross-origin-link", - ], + crossOriginLinks: ['https://example.com/cross-origin-link'], }; ``` @@ -629,3 +629,104 @@ window.$docsify = { topMargin: 90, // default: 0 }; ``` + +## vueComponents + +- type: `Object` + +Registers Vue components using the component name as the key with an object containing Vue options as the value. + +```js +window.$docsify = { + vueComponents: { + 'button-counter': { + template: ` + + `, + data() { + return { + count: 0, + }; + }, + }, + }, +}; +``` + +```markdown + +``` + + + + + +## vueGlobalOptions + +- type: `Object` + +Specifies Vue options to be shared throughout your site. These options will be used when Docsify detects Vue content in the main content area that has not been previously mounted via [vueOptions](#vueoptions), [vueComponents](#vuecomponents), or a markdown ` - + ``` -The URLs above will load a production version of Vue which is optimized for performance. Alternatively, development versions of Vue are larger but offer helpful console warnings and [Vue.js devtools](https://github.com/vuejs/vue-devtools) support: +The URLs above will load a **production** version of Vue which has been optimized for performance. Alternatively, **development** versions of Vue are available that are larger in size but offer helpful console warnings and [Vue.js devtools](https://github.com/vuejs/vue-devtools) support: ```html - + - + ``` ## Template syntax -Vue [template syntax](https://vuejs.org/v2/guide/syntax.html) can be added directly to your markdown pages. This syntax can be used to generate dynamic content without additional configuration using [JavaScript expressions](https://vuejs.org/v2/guide/syntax.html#Using-JavaScript-Expressions) and Vue [directives](https://vuejs.org/v2/guide/syntax.html#Directives). +Vue [template syntax](https://vuejs.org/v2/guide/syntax.html) is used to create dynamic content. With no additinal configuration, this syntax offers several useful features like support for [JavaScript expressions](https://vuejs.org/v2/guide/syntax.html#Using-JavaScript-Expressions) and Vue [directives](https://vuejs.org/v2/guide/syntax.html#Directives) for loops and conditional rendering. ```markdown - -

2 + 2 = {{ 2 + 2 }}

- - +

Text for GitHub

- + + + +

2 + 2 = {{ 2 + 2 }}

``` -

2 + 2 = {{ 2 + 2 }}

-

Text for GitHub

+ +

2 + 2 = {{ 2 + 2 }}

-[View markdown on GitHub](https://github.com/docsifyjs/docsify/blob/develop/docs/vue.md#template-syntax) +[View output on GitHub](https://github.com/docsifyjs/docsify/blob/develop/docs/vue.md#template-syntax) -Vue content becomes more interesting when data, methods, lifecycle hooks, and computed properties are used. These options can be specified as [global options](#global-options), [instance options](#instance-options), or within [components](#components). +Vue content becomes more interesting when [data](#data), [computed properties](#computed-properties), [methods](#methods), and [lifecycle hooks](#lifecycle-hooks) are used. These options can be specified as [global options](#global-options), [instance options](#instance-options), or within [components](#components). + +### Data ```js { data() { return { - message: 'Hello, World!', + message: 'Hello, World!' + }; + } +} +``` + + +```markdown + +{{ message }} + + +

+ + +

Text for GitHub

+``` + + + + +{{ message }} + +

+

Text for GitHub

+
+ +[View output on GitHub](https://github.com/docsifyjs/docsify/blob/develop/docs/vue.md#data) + +### Computed properties + +```js +{ + computed: { + timeOfDay() { + const date = new Date(); + const hours = date.getHours(); + + if (hours < 12) { + return 'morning'; + } + else if (hours < 18) { + return 'afternoon'; + } + else { + return 'evening' + } + } + }, +} +``` + +```markdown +Good {{ timeOfDay }}! +``` + + + +Good {{ timeOfDay }}! + + + +### Methods + +```js +{ + data() { + return { + message: 'Hello, World!' }; }, methods: { hello() { alert(this.message); } - } + }, } ``` -```markdown - -

- - -

Text for GitHub

- - -

- -

-``` - -

-

Text for GitHub

-[View markdown on GitHub](https://github.com/docsifyjs/docsify/blob/develop/docs/vue.md#options) +### Lifecycle Hooks + +```js +{ + data() { + return { + images: null, + }; + }, + created() { + fetch('https://api.domain.com/') + .then(response => response.json()) + .then(data => (this.images = data)) + .catch(err => console.log(err)); + } +} + +// API response: +// [ +// { title: 'Image 1', url: 'https://domain.com/1.jpg' }, +// { title: 'Image 2', url: 'https://domain.com/2.jpg' }, +// { title: 'Image 3', url: 'https://domain.com/3.jpg' }, +// ]; +``` + +```markdown +
+
+ +
{{ image.title }}
+
+
+``` + + +
+
+ +
{{ image.title }}
+
+
+
## Global options -Use `vueGlobalOptions` to share data, methods, lifecycle hooks, and computed properties throughout your site. These options will be available to Vue content not explicitly mounted via [instance options](#instance-options), [components](#components), or a markdown ` ``` @@ -222,9 +311,18 @@ TBD ``` -!> Only the first `