From d613527ed9bf922c8f02b6afb3a1b03d45dd0b40 Mon Sep 17 00:00:00 2001 From: Chris Waring Date: Wed, 7 Apr 2021 20:04:02 +0100 Subject: [PATCH] account for CANONICAL_BASE config --- .../plugins/vuepress-plugin-og-image/pageMeta-mixin.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/.vuepress/plugins/vuepress-plugin-og-image/pageMeta-mixin.js b/src/.vuepress/plugins/vuepress-plugin-og-image/pageMeta-mixin.js index 94998cef..642e6495 100644 --- a/src/.vuepress/plugins/vuepress-plugin-og-image/pageMeta-mixin.js +++ b/src/.vuepress/plugins/vuepress-plugin-og-image/pageMeta-mixin.js @@ -6,16 +6,17 @@ export default { const meta = this.$frontmatter.meta const og = meta && meta.find((m) => m.property === 'og:image') if (meta && og) { + const ogPath = new URL(og.content, 'http://locahost').pathname + const assetPath = normalize(ogPath).replace(/^\/|\/$/g, '') try { - const assetPath = normalize(og.content).replace(/^\/|\/$/g, '') const imgPath = require('@source/assets/' + assetPath) const { pageMeta } = this.$ssrContext this.$ssrContext.pageMeta = pageMeta.replace( - new RegExp(og.content, 'g'), + new RegExp(ogPath, 'g'), imgPath ) } catch (e) { - throw new Error(`could not load og:image ${og.content}`) + throw new Error(`could not load og:image ${ogPath}`) } } }