From 1b2f8cbe687f65edd409d02af95f283db3f5c462 Mon Sep 17 00:00:00 2001 From: Fatpandac Date: Wed, 3 Aug 2022 21:06:59 +0800 Subject: [PATCH] fix(plugin): fix page can not get version data (#2237) --- .../plugins/vuepress-plugin-loadVersion/index.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js b/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js index f90f33230..af38c04fb 100644 --- a/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js +++ b/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js @@ -14,20 +14,16 @@ exports.loadVersionPlugin = () => { .then((res) => res.response.docs[0].latestVersion); }; - const version = pom.project.properties.revision._text; + var version = pom.project.properties.revision._text; return { name: "vuepress-plugin-loadVersion", - extendsPage: async (page) => { - const injectVersionPagePaths = ["/", "/en/"]; - - if (!injectVersionPagePaths.includes(page.data.path)) return; - + onInitialized: async (app) => { if (version.includes("SNAPSHOT")) { - page.data.version = await getVersionByMaven(); - } else { - page.data.version = version; + version = await getVersionByMaven(); } + + app.pages.map((page) => (page.data.version = version)); }, }; };