From f72bf4cc9a27faa06a7d8dd85e953b8f4cf5ee19 Mon Sep 17 00:00:00 2001 From: Joe Pea Date: Thu, 21 May 2020 23:36:18 -0700 Subject: [PATCH] allow the user's $docsify config to be a function that receives as input the Docsify instance --- src/core/config.js | 6 ++++-- src/core/init/index.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/config.js b/src/core/config.js index c351790..981f4d0 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -2,7 +2,7 @@ import { merge, hyphenate, isPrimitive, hasOwn } from './util/core'; const currentScript = document.currentScript; -export default function() { +export default function(vm) { const config = merge( { el: '#app', @@ -35,7 +35,9 @@ export default function() { relativePath: false, topMargin: 0, }, - window.$docsify + typeof window.$docsify === 'function' + ? window.$docsify(vm) + : window.$docsify ); const script = diff --git a/src/core/init/index.js b/src/core/init/index.js index 9231acc..255aad0 100644 --- a/src/core/init/index.js +++ b/src/core/init/index.js @@ -9,7 +9,7 @@ import { initLifecycle, callHook } from './lifecycle'; export function initMixin(proto) { proto._init = function() { const vm = this; - vm.config = config(); + vm.config = config(vm); initLifecycle(vm); // Init hooks initPlugin(vm); // Install plugins