You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix docsify-ignore in seach title. ([#1872](https://github.com/docsifyjs/docsify/issues/1872)) ([9832805](https://github.com/docsifyjs/docsify/commit/9832805681cc6099e9c78deecf6dc0c6fb61fd9b))
11
+
* fix search with no content. ([#1878](https://github.com/docsifyjs/docsify/issues/1878)) ([9b74744](https://github.com/docsifyjs/docsify/commit/9b74744299ece0108573a142e5a2e949dc569254))
* Legacy bugs (styles, site plugin error, and dev server error) ([#1743](https://github.com/docsifyjs/docsify/issues/1743)) ([fa6df6d](https://github.com/docsifyjs/docsify/commit/fa6df6d58487ec294e22be04ac159dfb5745bd66))
14
+
* package.json & package-lock.json to reduce vulnerabilities ([#1756](https://github.com/docsifyjs/docsify/issues/1756)) ([2dc5b12](https://github.com/docsifyjs/docsify/commit/2dc5b12b715e3ad1922a6401e3fd9837a99ef9c0))
15
+
* packages/docsify-server-renderer/package.json & packages/docsify-server-renderer/package-lock.json to reduce vulnerabilities ([#1715](https://github.com/docsifyjs/docsify/issues/1715)) ([c1227b2](https://github.com/docsifyjs/docsify/commit/c1227b22cb8a3fb6c362ca8ac109082ab2251cc3))
Copy file name to clipboardExpand all lines: docs/configuration.md
+86Lines changed: 86 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ The config can also be defined as a function, in which case the first argument i
35
35
- Type: `Object`
36
36
37
37
Set the route alias. You can freely manage routing rules. Supports RegExp.
38
+
Do note that order matters! If a route can be matched by multiple aliases, the one you declared first takes precedence.
38
39
39
40
```js
40
41
window.$docsify= {
@@ -680,6 +681,91 @@ window.$docsify = {
680
681
};
681
682
```
682
683
684
+
## routes
685
+
686
+
- Type: `Object`
687
+
688
+
Define "virtual" routes that can provide content dynamically. A route is a map between the expected path, to either a string or a function. If the mapped value is a string, it is treated as markdown and parsed accordingly. If it is a function, it is expected to return markdown content.
689
+
690
+
A route function receives up to three parameters:
691
+
1.`route` - the path of the route that was requested (e.g. `/bar/baz`)
692
+
2.`matched` - the [`RegExpMatchArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) that was matched by the route (e.g. for `/bar/(.+)`, you get `['/bar/baz', 'baz']`)
693
+
3.`next` - this is a callback that you may call when your route function is async
694
+
695
+
Do note that order matters! Routes are matched the same order you declare them in, which means that in cases where you have overlapping routes, you might want to list the more specific ones first.
696
+
697
+
```js
698
+
window.$docsify= {
699
+
routes: {
700
+
// Basic match w/ return string
701
+
'/foo':'# Custom Markdown',
702
+
703
+
// RegEx match w/ synchronous function
704
+
'/bar/(.*)':function(route, matched) {
705
+
return'# Custom Markdown';
706
+
},
707
+
708
+
// RegEx match w/ asynchronous function
709
+
'/baz/(.*)':function(route, matched, next) {
710
+
// Requires `fetch` polyfill for legacy browsers (https://github.github.io/fetch/)
711
+
fetch('/api/users?id=12345')
712
+
.then(function(response) {
713
+
next('# Custom Markdown');
714
+
})
715
+
.catch(function(err) {
716
+
// Handle error...
717
+
});
718
+
}
719
+
}
720
+
}
721
+
```
722
+
723
+
Other than strings, route functions can return a falsy value (`null` \ `undefined`) to indicate that they ignore the current request:
724
+
725
+
```js
726
+
window.$docsify= {
727
+
routes: {
728
+
// accepts everything other than dogs (synchronous)
729
+
'/pets/(.+)':function(route, matched) {
730
+
if (matched[0] ==='dogs') {
731
+
returnnull;
732
+
} else {
733
+
return'I like all pets but dogs';
734
+
}
735
+
}
736
+
737
+
// accepts everything other than cats (asynchronous)
738
+
'/pets/(.*)':function(route, matched, next) {
739
+
if (matched[0] ==='cats') {
740
+
next();
741
+
} else {
742
+
// Async task(s)...
743
+
next('I like all pets but cats');
744
+
}
745
+
}
746
+
}
747
+
}
748
+
```
749
+
750
+
Finally, if you have a specific path that has a real markdown file (and therefore should not be matched by your route), you can opt it out by returning an explicit `false` value:
751
+
752
+
```js
753
+
window.$docsify= {
754
+
routes: {
755
+
// if you look up /pets/cats, docsify will skip all routes and look for "pets/cats.md"
756
+
'/pets/cats':function(route, matched) {
757
+
returnfalse;
758
+
}
759
+
760
+
// but any other pet should generate dynamic content right here
Copy file name to clipboardExpand all lines: docs/deploy.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,14 @@ Similar to [GitBook](https://www.gitbook.com), you can deploy files to GitHub Pa
7
7
There are three places to populate your docs for your GitHub repository:
8
8
9
9
-`docs/` folder
10
-
-master branch
10
+
-main branch
11
11
- gh-pages branch
12
12
13
-
It is recommended that you save your files to the `./docs` subfolder of the `master` branch of your repository. Then select `master branch /docs folder` as your GitHub Pages source in your repository's settings page.
13
+
It is recommended that you save your files to the `./docs` subfolder of the `main` branch of your repository. Then select `main branch /docs folder` as your GitHub Pages source in your repository's settings page.
14
14
15
15

16
16
17
-
!> You can also save files in the root directory and select `master branch`.
17
+
!> You can also save files in the root directory and select `main branch`.
18
18
You'll need to place a `.nojekyll` file in the deploy location (such as `/docs` or the gh-pages branch)
0 commit comments