From 0fdd49a5511492ede7ca8c02603e8ed39b7937c2 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Fri, 21 Aug 2026 13:28:07 -0700 Subject: [PATCH] Adds Open Graph plugin --- docs/.vuepress/config.js | 1 + docs/.vuepress/plugins/og.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 docs/.vuepress/plugins/og.js diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 7fcff79c8..07efa6d52 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -32,6 +32,7 @@ module.exports = { } ], [require("./plugins/craft.js")], + [require("./plugins/og.js")], ], shouldPrefetch: () => false, head: require("./head"), diff --git a/docs/.vuepress/plugins/og.js b/docs/.vuepress/plugins/og.js new file mode 100644 index 000000000..05a713526 --- /dev/null +++ b/docs/.vuepress/plugins/og.js @@ -0,0 +1,26 @@ +module.exports = function(options, ctx) { + return { + name: 'og', + extendPageData(page) { + + const path = (page.regularPath || '/') + .replace(/\/+$/, '') + .replace(/\.html$/, ''); + + // https://craftcms.com/api/og-image/docs/5.x/editions + const newFrontmatter = [ + { + property: 'og:image', + content: `https://craftcms.com/api/og-image/docs${path}` + }, + ]; + + const frontmatter = [ + ...(page.frontmatter.meta || []), + ...newFrontmatter, + ]; + + page.frontmatter.meta = frontmatter; + } + } +}