mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-29 03:47:04 +08:00
feat(hook): new hook updateNav for update navbar content
This commit is contained in:
+5
-2
@@ -55,6 +55,9 @@
|
||||
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||
plugins: [
|
||||
function (hook, vm) {
|
||||
hook.updateNav(function(nav){
|
||||
return `${nav}\n- lol`
|
||||
}),
|
||||
hook.beforeEach(function (html) {
|
||||
if (/githubusercontent\.com/.test(vm.route.file)) {
|
||||
url = vm.route.file
|
||||
@@ -79,9 +82,9 @@
|
||||
}
|
||||
</script>
|
||||
<script src="/lib/docsify.js"></script>
|
||||
<script src="/lib/plugins/search.js"></script>
|
||||
<!-- <script src="/lib/plugins/search.js"></script>
|
||||
<script src="/lib/plugins/emoji.js"></script>
|
||||
<script src="/lib/plugins/front-matter.js"></script>
|
||||
<script src="/lib/plugins/front-matter.js"></script> -->
|
||||
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>
|
||||
|
||||
@@ -5,6 +5,7 @@ export function initLifecycle(vm) {
|
||||
'init',
|
||||
'mounted',
|
||||
'beforeEach',
|
||||
'updateNav',
|
||||
'afterEach',
|
||||
'doneEach',
|
||||
'ready',
|
||||
|
||||
@@ -140,7 +140,13 @@ export function renderMixin(proto) {
|
||||
};
|
||||
|
||||
proto._renderNav = function(text) {
|
||||
text && this._renderTo('nav', this.compiler.compile(text));
|
||||
if (text) {
|
||||
callHook(this, 'updateNav', text, result => {
|
||||
text = result || text;
|
||||
this._renderTo('nav', this.compiler.compile(text));
|
||||
});
|
||||
}
|
||||
|
||||
if (this.config.loadNavbar) {
|
||||
getAndActive(this.router, 'nav');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user