From ec138b2ee956976458a33b2148aa5e669395a2e1 Mon Sep 17 00:00:00 2001 From: Chris Waring Date: Wed, 7 Apr 2021 18:53:46 +0100 Subject: [PATCH] normalize paths --- .../plugins/vuepress-plugin-og-image/pageMeta-mixin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 c62dd1d9..94998cef 100644 --- a/src/.vuepress/plugins/vuepress-plugin-og-image/pageMeta-mixin.js +++ b/src/.vuepress/plugins/vuepress-plugin-og-image/pageMeta-mixin.js @@ -1,3 +1,5 @@ +const { normalize } = require('path') + export default { created() { if (typeof this.$ssrContext !== 'undefined') { @@ -5,7 +7,8 @@ export default { const og = meta && meta.find((m) => m.property === 'og:image') if (meta && og) { try { - const imgPath = require('@source/assets/' + og.content) + 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'),