diff --git a/packages/@vuepress/core/lib/client/clientEntry.js b/packages/@vuepress/core/lib/client/clientEntry.js index b7f795f613..7a8e568f5d 100644 --- a/packages/@vuepress/core/lib/client/clientEntry.js +++ b/packages/@vuepress/core/lib/client/clientEntry.js @@ -4,7 +4,7 @@ import { createApp } from './app' const { app, router } = createApp(false /* isServer */) -window.__VUEPRESS_VERSION__ = { +window.__VUEPRESS__ = { version: VUEPRESS_VERSION, hash: LAST_COMMIT_HASH } diff --git a/packages/@vuepress/core/lib/client/components/Content.js b/packages/@vuepress/core/lib/client/components/Content.js index 126dba6fb2..cc06182820 100644 --- a/packages/@vuepress/core/lib/client/components/Content.js +++ b/packages/@vuepress/core/lib/client/components/Content.js @@ -1,3 +1,4 @@ +import { setGlobalInfo } from '@app/util' export default { props: { @@ -9,6 +10,8 @@ export default { }, render (h) { const pageKey = this.pageKey || this.$parent.$page.key + setGlobalInfo('pageKey', pageKey) + if (pageKey) { return h(pageKey) } diff --git a/packages/@vuepress/core/lib/client/components/GlobalLayout.vue b/packages/@vuepress/core/lib/client/components/GlobalLayout.vue index 077c65a59b..72f28a76f1 100644 --- a/packages/@vuepress/core/lib/client/components/GlobalLayout.vue +++ b/packages/@vuepress/core/lib/client/components/GlobalLayout.vue @@ -3,9 +3,11 @@ diff --git a/packages/@vuepress/core/lib/client/util.js b/packages/@vuepress/core/lib/client/util.js index 02b85feefe..65b814d783 100644 --- a/packages/@vuepress/core/lib/client/util.js +++ b/packages/@vuepress/core/lib/client/util.js @@ -182,3 +182,16 @@ export function normalizeConfig (component, rawConfig) { } return rawConfig } + +/** + * Set global info in `window.__VUEPRESS__` for debugging. + * + * @param {string}key + * @param {any} value + */ +export function setGlobalInfo (key, value) { + if (!window.__VUEPRESS__ || typeof window === 'undefined') { + return + } + window.__VUEPRESS__[key] = value +}