nuxt-og-image 3.0.0-rc.3 → 3.0.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/client/200.html +226 -15
- package/dist/client/404.html +226 -15
- package/dist/client/_nuxt/{IconCSS.a9e1bda0.js → IconCSS.CZ8ZjA39.js} +1 -1
- package/dist/client/_nuxt/IconCSS.UISSK5sv.css +1 -0
- package/dist/client/_nuxt/abap.bJqzlTLD.js +816 -0
- package/dist/client/_nuxt/actionscript-3.NUzLYz6e.js +1 -0
- package/dist/client/_nuxt/ada.HSb8VHJ5.js +1 -0
- package/dist/client/_nuxt/andromeeda.TE0Toi4a.js +1 -0
- package/dist/client/_nuxt/angular-html.ngCY688K.js +16 -0
- package/dist/client/_nuxt/angular-ts.JfRveWw0.js +666 -0
- package/dist/client/_nuxt/apache.TpqIaH_y.js +1 -0
- package/dist/client/_nuxt/apex.rLr5RF8N.js +274 -0
- package/dist/client/_nuxt/apl.ojEktQcO.js +87 -0
- package/dist/client/_nuxt/applescript.uEUaUzem.js +38 -0
- package/dist/client/_nuxt/ara.yxVemEif.js +21 -0
- package/dist/client/_nuxt/asm.N3zWSyW8.js +1 -0
- package/dist/client/_nuxt/astro.bVipJGkW.js +1 -0
- package/dist/client/_nuxt/aurora-x.23vffHpO.js +1 -0
- package/dist/client/_nuxt/awk.tQAliBPt.js +1 -0
- package/dist/client/_nuxt/ayu-dark.09-XTo9D.js +1 -0
- package/dist/client/_nuxt/ballerina.j08zL6tL.js +62 -0
- package/dist/client/_nuxt/bat.4hprCtpO.js +1 -0
- package/dist/client/_nuxt/beancount.B4bgLeBI.js +1 -0
- package/dist/client/_nuxt/berry.99Qqo7Pl.js +1 -0
- package/dist/client/_nuxt/bibtex.PUS4KD1G.js +1 -0
- package/dist/client/_nuxt/bicep.U1vZFTkg.js +1 -0
- package/dist/client/_nuxt/blade.HvKjdph-.js +831 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/bb98bdc4-cb43-44eb-b961-cca8b9050d48.json +1 -0
- package/dist/client/_nuxt/c.1HqcaTLZ.js +81 -0
- package/dist/client/_nuxt/cadence.wPBjDAPG.js +1 -0
- package/dist/client/_nuxt/catppuccin-frappe.3zzElYQH.js +1 -0
- package/dist/client/_nuxt/catppuccin-latte.7_seQpm6.js +1 -0
- package/dist/client/_nuxt/catppuccin-macchiato.xyLZ1Mzm.js +1 -0
- package/dist/client/_nuxt/catppuccin-mocha.sKQhYBeR.js +1 -0
- package/dist/client/_nuxt/clarity.9V3ikNUm.js +1 -0
- package/dist/client/_nuxt/clojure.m464_LIc.js +1 -0
- package/dist/client/_nuxt/cmake.YiKLaZ9A.js +1 -0
- package/dist/client/_nuxt/cobol.DIpfQcy2.js +1 -0
- package/dist/client/_nuxt/codeql.i7fhVOvX.js +1 -0
- package/dist/client/_nuxt/coffee.09Ode5TL.js +100 -0
- package/dist/client/_nuxt/cpp.UIU91NPT.js +186 -0
- package/dist/client/_nuxt/crystal.KqWgScGa.js +25 -0
- package/dist/client/_nuxt/csharp.SlsguwGx.js +755 -0
- package/dist/client/_nuxt/css.tuEqSfZX.js +505 -0
- package/dist/client/_nuxt/csv.REIP-dDb.js +1 -0
- package/dist/client/_nuxt/cue.ts9p4IYJ.js +1 -0
- package/dist/client/_nuxt/cypher.y2dXjvht.js +1 -0
- package/dist/client/_nuxt/d.91KOtcJM.js +1 -0
- package/dist/client/_nuxt/dark-plus.kgh98KCl.js +1 -0
- package/dist/client/_nuxt/dart.ATU8nP6d.js +1 -0
- package/dist/client/_nuxt/dax.M4oDHFBw.js +29 -0
- package/dist/client/_nuxt/diff.-l9-nN5b.js +1 -0
- package/dist/client/_nuxt/docker.FKXxym4E.js +1 -0
- package/dist/client/_nuxt/dracula-soft.E92bUq8i.js +1 -0
- package/dist/client/_nuxt/dracula.mNVTF5-9.js +1 -0
- package/dist/client/_nuxt/dream-maker.5lPMrnJr.js +52 -0
- package/dist/client/_nuxt/elixir.Q1fiwhg2.js +17 -0
- package/dist/client/_nuxt/elm.AR6G1sGv.js +1 -0
- package/dist/client/_nuxt/entry.OczI2MjB.css +1 -0
- package/dist/client/_nuxt/entry.v1zp98GR.js +134 -0
- package/dist/client/_nuxt/erb.K_ppY6Ln.js +1 -0
- package/dist/client/_nuxt/erlang._Br9gip-.js +1 -0
- package/dist/client/_nuxt/error-404.DkXpI38i.css +1 -0
- package/dist/client/_nuxt/{error-404.b7c0506a.js → error-404.VV5ycc25.js} +1 -1
- package/dist/client/_nuxt/{error-500.c45b2f29.js → error-500.VNY3c4OJ.js} +1 -1
- package/dist/client/_nuxt/fish.k6NZEVUm.js +5 -0
- package/dist/client/_nuxt/fsharp.37PDbGQ_.js +1 -0
- package/dist/client/_nuxt/gdresource.7GKJFf55.js +1 -0
- package/dist/client/_nuxt/gdscript.E1_SGClP.js +44 -0
- package/dist/client/_nuxt/gdshader.6pjKCTQy.js +1 -0
- package/dist/client/_nuxt/gherkin.hgsyILVZ.js +1 -0
- package/dist/client/_nuxt/git-commit.RtAxFnK2.js +1 -0
- package/dist/client/_nuxt/git-rebase.-_3Z3F37.js +1 -0
- package/dist/client/_nuxt/github-dark-dimmed.yDYFqRVv.js +1 -0
- package/dist/client/_nuxt/github-dark.WrpzPehD.js +1 -0
- package/dist/client/_nuxt/github-light.QjB713Ax.js +1 -0
- package/dist/client/_nuxt/glimmer-js.OxCy_kio.js +1 -0
- package/dist/client/_nuxt/glimmer-ts.ZLbawe8H.js +1 -0
- package/dist/client/_nuxt/glsl.yLv_V-GM.js +1 -0
- package/dist/client/_nuxt/gnuplot.fIlAWhXw.js +266 -0
- package/dist/client/_nuxt/go.2bJKq9hO.js +1 -0
- package/dist/client/_nuxt/graphql.Mw2TwDQV.js +4 -0
- package/dist/client/_nuxt/groovy.Z1Lrhk2B.js +37 -0
- package/dist/client/_nuxt/hack.8bxbrxw3.js +86 -0
- package/dist/client/_nuxt/haml.9njXWWYk.js +1 -0
- package/dist/client/_nuxt/handlebars.e6aZXt-Z.js +1 -0
- package/dist/client/_nuxt/haskell.HW0BBkRd.js +559 -0
- package/dist/client/_nuxt/hcl.M9siRbiv.js +1 -0
- package/dist/client/_nuxt/hjson.fLk7JbZa.js +50 -0
- package/dist/client/_nuxt/hlsl.Do_j-o-7.js +1 -0
- package/dist/client/_nuxt/html.q2IluNCo.js +74 -0
- package/dist/client/_nuxt/http.suDZEQUg.js +1 -0
- package/dist/client/_nuxt/imba.Shm_xfQD.js +223 -0
- package/dist/client/_nuxt/ini.T6bxBy5-.js +1 -0
- package/dist/client/_nuxt/java.tY-NU26U.js +68 -0
- package/dist/client/_nuxt/javascript.4rbEI_qn.js +699 -0
- package/dist/client/_nuxt/jinja.E4nwqofd.js +1 -0
- package/dist/client/_nuxt/jison.gkHJeffy.js +1 -0
- package/dist/client/_nuxt/json.xL80yL3n.js +25 -0
- package/dist/client/_nuxt/json5.NRuQoh_0.js +17 -0
- package/dist/client/_nuxt/jsonc.Bb1R3obU.js +25 -0
- package/dist/client/_nuxt/jsonl.Yjg0VwMG.js +25 -0
- package/dist/client/_nuxt/jsonnet.WK26vH-O.js +1 -0
- package/dist/client/_nuxt/jssm.eioTUq4-.js +1 -0
- package/dist/client/_nuxt/jsx.O5ZRGASz.js +699 -0
- package/dist/client/_nuxt/julia.ku4F-e-8.js +9 -0
- package/dist/client/_nuxt/kotlin.1iwCeGA4.js +1 -0
- package/dist/client/_nuxt/kusto.UpRCclYC.js +1 -0
- package/dist/client/_nuxt/latex.6xV8tHRw.js +3 -0
- package/dist/client/_nuxt/less.Mq8TrjER.js +159 -0
- package/dist/client/_nuxt/light-plus.TzXGjDsL.js +1 -0
- package/dist/client/_nuxt/liquid.O0W9gNJ1.js +14 -0
- package/dist/client/_nuxt/lisp.iIZdsWzX.js +1 -0
- package/dist/client/_nuxt/logo.WuHqTpFy.js +1 -0
- package/dist/client/_nuxt/lua.OGbZEs3U.js +1 -0
- package/dist/client/_nuxt/make.8zIAVqFD.js +1 -0
- package/dist/client/_nuxt/markdown.Y8p9X7h3.js +129 -0
- package/dist/client/_nuxt/marko.sELZHXF6.js +8 -0
- package/dist/client/_nuxt/material-theme-darker.e1lAwchJ.js +1 -0
- package/dist/client/_nuxt/material-theme-lighter.y77yPuAI.js +1 -0
- package/dist/client/_nuxt/material-theme-ocean.oIMAIpse.js +1 -0
- package/dist/client/_nuxt/material-theme-palenight.Z44VU5rQ.js +1 -0
- package/dist/client/_nuxt/material-theme.49YjOoAR.js +1 -0
- package/dist/client/_nuxt/matlab.LaB98_jd.js +70 -0
- package/dist/client/_nuxt/mdc.NowVT77H.js +76 -0
- package/dist/client/_nuxt/mdx.VhCSg2DJ.js +1 -0
- package/dist/client/_nuxt/mermaid.WuNnVULj.js +1 -0
- package/dist/client/_nuxt/min-dark._Ja8ZF5C.js +1 -0
- package/dist/client/_nuxt/min-light.N1m_6E3S.js +1 -0
- package/dist/client/_nuxt/mojo.zLNDSfD9.js +519 -0
- package/dist/client/_nuxt/monokai.WLw4Glvg.js +1 -0
- package/dist/client/_nuxt/narrat.KYi2rZr0.js +7 -0
- package/dist/client/_nuxt/nextflow.lYJjOZ_l.js +1 -0
- package/dist/client/_nuxt/nginx.CrBM8z2W.js +1 -0
- package/dist/client/_nuxt/night-owl.GWZK5Ce7.js +1 -0
- package/dist/client/_nuxt/nim.OZ1TiK9r.js +1 -0
- package/dist/client/_nuxt/nix.z3u_V08Q.js +1 -0
- package/dist/client/_nuxt/nord.1NrVtx79.js +1 -0
- package/dist/client/_nuxt/nushell.GDk9yul-.js +1 -0
- package/dist/client/_nuxt/objective-c.Eci2Q5FN.js +109 -0
- package/dist/client/_nuxt/objective-cpp.nGsV46Zk.js +239 -0
- package/dist/client/_nuxt/ocaml.oQRvlYTD.js +1 -0
- package/dist/client/_nuxt/one-dark-pro.qlkgvdEn.js +1 -0
- package/dist/client/_nuxt/onig.mBJmD8D5.js +1 -0
- package/dist/client/_nuxt/pascal.aIRIFbih.js +1 -0
- package/dist/client/_nuxt/perl.CaKiGeyl.js +1 -0
- package/dist/client/_nuxt/php.Q2jqa0n_.js +771 -0
- package/dist/client/_nuxt/plsql.vhhXsReo.js +1 -0
- package/dist/client/_nuxt/poimandres.oZrO-I17.js +1 -0
- package/dist/client/_nuxt/postcss.57yKeRpx.js +1 -0
- package/dist/client/_nuxt/powerquery.wBQvr9E-.js +1 -0
- package/dist/client/_nuxt/powershell.6Y_bsqLY.js +1 -0
- package/dist/client/_nuxt/prisma.fG9Ut-9i.js +1 -0
- package/dist/client/_nuxt/prolog.vggnm0Hd.js +1 -0
- package/dist/client/_nuxt/proto.yigfBmiL.js +1 -0
- package/dist/client/_nuxt/pug.dmyiUMO7.js +1 -0
- package/dist/client/_nuxt/puppet.NqXa_cO1.js +1 -0
- package/dist/client/_nuxt/purescript.NA5qsvV2.js +7 -0
- package/dist/client/_nuxt/python.V9Nu427R.js +518 -0
- package/dist/client/_nuxt/r.xMXDrvl2.js +1 -0
- package/dist/client/_nuxt/raku.NSWyGF40.js +1 -0
- package/dist/client/_nuxt/razor.X4IfBpol.js +40 -0
- package/dist/client/_nuxt/red.sV5NnIRC.js +1 -0
- package/dist/client/_nuxt/reg.Dr-lXfN9.js +1 -0
- package/dist/client/_nuxt/rel.vATIbX_E.js +1 -0
- package/dist/client/_nuxt/riscv.L73dAZEB.js +13 -0
- package/dist/client/_nuxt/rose-pine-dawn.qPi4euik.js +1 -0
- package/dist/client/_nuxt/rose-pine-moon.Im6VgKOx.js +1 -0
- package/dist/client/_nuxt/rose-pine._tQyNI4L.js +1 -0
- package/dist/client/_nuxt/rst.GKtlS3h3.js +1 -0
- package/dist/client/_nuxt/ruby.P9eGVNW4.js +80 -0
- package/dist/client/_nuxt/rust.FLHuhIzG.js +1 -0
- package/dist/client/_nuxt/sas.fTu4QUYF.js +1 -0
- package/dist/client/_nuxt/sass.URKSWxt9.js +2 -0
- package/dist/client/_nuxt/scala.7DKpDMtV.js +5 -0
- package/dist/client/_nuxt/scheme.S0VUhbaV.js +136 -0
- package/dist/client/_nuxt/scss.9u5wOjnF.js +90 -0
- package/dist/client/_nuxt/shaderlab.MYTNW71C.js +1 -0
- package/dist/client/_nuxt/shellscript.82BvnTib.js +4 -0
- package/dist/client/_nuxt/shellsession.e2TODbDv.js +1 -0
- package/dist/client/_nuxt/slack-dark.1ZggNzwg.js +1 -0
- package/dist/client/_nuxt/slack-ochin.IcMt0x71.js +1 -0
- package/dist/client/_nuxt/smalltalk.ymyryZ3T.js +1 -0
- package/dist/client/_nuxt/solarized-dark.3DcwRX9o.js +1 -0
- package/dist/client/_nuxt/solarized-light.iUVMuJ2F.js +1 -0
- package/dist/client/_nuxt/solidity.rGqtk2dD.js +1 -0
- package/dist/client/_nuxt/sparql.b6B4dWwT.js +1 -0
- package/dist/client/_nuxt/splunk.OYnOZZCZ.js +1 -0
- package/dist/client/_nuxt/sql.KWFjTZGI.js +21 -0
- package/dist/client/_nuxt/ssh-config.jdYjUr9x.js +1 -0
- package/dist/client/_nuxt/stata.cF_ucIcM.js +3 -0
- package/dist/client/_nuxt/stylus.sPHLw37c.js +15 -0
- package/dist/client/_nuxt/svelte.6zdtIlwM.js +1 -0
- package/dist/client/_nuxt/swift.YwiPyWKn.js +544 -0
- package/dist/client/_nuxt/synthwave-84.QD7ZGwpp.js +1 -0
- package/dist/client/_nuxt/system-verilog.gwJe9XJI.js +9 -0
- package/dist/client/_nuxt/tasl.IM3fg-4x.js +1 -0
- package/dist/client/_nuxt/tcl.h_zrCUh3.js +1 -0
- package/dist/client/_nuxt/tex.uNByjuDB.js +1 -0
- package/dist/client/_nuxt/tokyo-night.3j08uV2M.js +1 -0
- package/dist/client/_nuxt/toml.p_xIKQcU.js +69 -0
- package/dist/client/_nuxt/tsx.vbVEYvAd.js +699 -0
- package/dist/client/_nuxt/turtle.qvOLXpiq.js +1 -0
- package/dist/client/_nuxt/twig.h5iAhXmS.js +40 -0
- package/dist/client/_nuxt/typescript.IWNmnGsa.js +666 -0
- package/dist/client/_nuxt/v.BcVLQyAr.js +1 -0
- package/dist/client/_nuxt/vanilla-picker.P0dws0ou.js +8 -0
- package/dist/client/_nuxt/vb.nfm3ZogP.js +1 -0
- package/dist/client/_nuxt/verilog.32GaFvLA.js +1 -0
- package/dist/client/_nuxt/vhdl.BgfvI7C9.js +515 -0
- package/dist/client/_nuxt/viml.Ob-szSvk.js +1 -0
- package/dist/client/_nuxt/vitesse-black.uLlG6AUB.js +1 -0
- package/dist/client/_nuxt/vitesse-dark.5VceXvs6.js +1 -0
- package/dist/client/_nuxt/vitesse-light.HOMMxGxw.js +1 -0
- package/dist/client/_nuxt/vue-html.B2XvVFLk.js +1 -0
- package/dist/client/_nuxt/vue.CmUal76M.js +6 -0
- package/dist/client/_nuxt/vyper.0ItMHLZu.js +575 -0
- package/dist/client/_nuxt/wasm.5qeU6UJI.js +1 -0
- package/dist/client/_nuxt/wenyan.gl1zQYA8.js +1 -0
- package/dist/client/_nuxt/wgsl.KpVp-DWl.js +1 -0
- package/dist/client/_nuxt/wolfram.K_QzNdW-.js +1 -0
- package/dist/client/_nuxt/xml.GygmfNh9.js +1 -0
- package/dist/client/_nuxt/xsl.TptR0G-3.js +1 -0
- package/dist/client/_nuxt/yaml.zytfnWoA.js +200 -0
- package/dist/client/_nuxt/zenscript.htRIWiQY.js +2 -0
- package/dist/client/_nuxt/zig.VzlkOal1.js +1 -0
- package/dist/client/index.html +226 -15
- package/dist/module.d.mts +4 -3
- package/dist/module.d.ts +4 -3
- package/dist/module.json +2 -2
- package/dist/module.mjs +110 -87
- package/dist/runtime/components/OgImage/OgImage.d.ts +1 -1
- package/dist/runtime/components/OgImage/OgImageScreenshot.d.ts +1 -1
- package/dist/runtime/components/Templates/Community/NuxtSeo.vue +1 -1
- package/dist/runtime/components/Templates/Community/UnJs.vue +2 -2
- package/dist/runtime/composables/defineOgImage.mjs +4 -9
- package/dist/runtime/core/bindings/chromium/chrome-launcher.mjs +9 -0
- package/dist/runtime/core/bindings/chromium/on-demand.d.ts +2 -0
- package/dist/runtime/core/bindings/chromium/on-demand.mjs +36 -0
- package/dist/runtime/core/bindings/chromium/playwright.d.ts +2 -0
- package/dist/runtime/core/bindings/chromium/playwright.mjs +6 -0
- package/dist/runtime/core/bindings/css-inline/node.d.ts +8 -2
- package/dist/runtime/core/bindings/css-inline/node.mjs +7 -2
- package/dist/runtime/core/bindings/css-inline/wasm-fs.d.ts +8 -0
- package/dist/runtime/core/bindings/css-inline/wasm-fs.mjs +8 -0
- package/dist/runtime/core/bindings/css-inline/wasm.d.ts +8 -0
- package/dist/runtime/core/bindings/css-inline/wasm.mjs +8 -0
- package/dist/runtime/core/font/fetch.mjs +4 -1
- package/dist/runtime/core/html/applyInlineCss.mjs +26 -19
- package/dist/runtime/core/html/devIframeTemplate.mjs +3 -2
- package/dist/runtime/core/options/extract.d.ts +1 -0
- package/dist/runtime/core/options/extract.mjs +9 -0
- package/dist/runtime/core/renderers/satori/index.mjs +6 -5
- package/dist/runtime/core/renderers/satori/instances.mjs +2 -1
- package/dist/runtime/core/renderers/satori/plugins/encoding.mjs +14 -5
- package/dist/runtime/core/renderers/satori/plugins/imageSrc.mjs +49 -40
- package/dist/runtime/core/renderers/satori/vnodes.mjs +3 -1
- package/dist/runtime/core/utils/resolveRendererContext.mjs +5 -9
- package/dist/runtime/nitro/kit.d.ts +3 -0
- package/dist/runtime/nitro/kit.mjs +23 -0
- package/dist/runtime/nitro/plugins/nuxt-content.mjs +6 -3
- package/dist/runtime/nitro/plugins/prerender.d.ts +1 -1
- package/dist/runtime/nitro/plugins/prerender.mjs +5 -12
- package/dist/runtime/{server → nitro}/routes/__og-image__/debug.json.d.ts +0 -4
- package/dist/runtime/{server → nitro}/routes/__og-image__/debug.json.mjs +0 -6
- package/dist/runtime/nitro/routes/__og-image__/font-[name]-[weight].[extension].mjs +56 -0
- package/dist/runtime/{server → nitro}/routes/__og-image__/image.mjs +4 -3
- package/dist/runtime/nitro/tsconfig.json +3 -0
- package/dist/runtime/nitro/utils.mjs +1 -2
- package/dist/runtime/nuxt/plugins/og-image-canonical-urls.server.mjs +9 -2
- package/dist/runtime/nuxt/utils.d.ts +2 -1
- package/dist/runtime/nuxt/utils.mjs +5 -3
- package/dist/runtime/types.d.ts +5 -3
- package/dist/runtime/utils.pure.d.ts +2 -0
- package/dist/runtime/utils.pure.mjs +9 -1
- package/dist/types.d.mts +2 -2
- package/package.json +67 -44
- package/dist/client/_nuxt/IconCSS.f0b56d3e.css +0 -1
- package/dist/client/_nuxt/builds/meta/f6f30fc8-72d3-4090-90f8-10aeee14e041.json +0 -1
- package/dist/client/_nuxt/entry.a30f63d0.css +0 -1
- package/dist/client/_nuxt/entry.dd086114.js +0 -108
- package/dist/client/_nuxt/error-404.b751fa02.css +0 -1
- package/dist/client/_nuxt/vanilla-picker-NKbIFE8h.23409a58.js +0 -8
- package/dist/runtime/core/bindings/chromium/node.mjs +0 -33
- package/dist/runtime/server/routes/__og-image__/font-[name]-[weight].[extension].mjs +0 -30
- /package/dist/client/_nuxt/{error-500.69009e70.css → error-500.SLhS9LVu.css} +0 -0
- /package/dist/runtime/core/bindings/chromium/{node.d.ts → chrome-launcher.d.ts} +0 -0
- /package/dist/runtime/{server → nitro}/routes/__og-image__/font-[name]-[weight].[extension].d.ts +0 -0
- /package/dist/runtime/{server → nitro}/routes/__og-image__/image.d.ts +0 -0
|
@@ -3,30 +3,37 @@ import { useNitroOrigin } from "#imports";
|
|
|
3
3
|
import cssInline from "#nuxt-og-image/bindings/css-inline";
|
|
4
4
|
export async function applyInlineCss({ e }, island) {
|
|
5
5
|
let html = island.html;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
if (!cssInline.__unenv__) {
|
|
7
|
+
let css = island.head.style.map((s) => s.innerHTML).join("\n");
|
|
8
|
+
const componentInlineStyles = island.head.link.filter((l) => l.href.startsWith("/_nuxt/components"));
|
|
9
|
+
if (process.dev) {
|
|
10
|
+
const linksToCss = componentInlineStyles.length ? (await Promise.all(
|
|
11
|
+
componentInlineStyles.map((l) => {
|
|
12
|
+
const url = l.href.endsWith("lang.css") ? `${l.href}&hmr=false` : l.href;
|
|
13
|
+
return e.$fetch(url, {
|
|
14
|
+
responseType: "text",
|
|
15
|
+
baseURL: useNitroOrigin(e)
|
|
16
|
+
}).then((res) => {
|
|
17
|
+
if (res.includes("__vite__css"))
|
|
18
|
+
return res.match(/__vite__css = "([^"]+)"/)?.[1];
|
|
19
|
+
return res.trim().split("\n").filter((l2) => !l2.startsWith("//")).join("\n").trim();
|
|
20
|
+
});
|
|
21
|
+
})
|
|
22
|
+
)).join("\n") : "";
|
|
23
|
+
css = `${linksToCss}${css}`;
|
|
24
|
+
}
|
|
25
|
+
if (!css.trim().length)
|
|
26
|
+
return false;
|
|
21
27
|
const cssInline2 = await useCssInline();
|
|
22
28
|
html = cssInline2.inline(island.html, {
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
loadRemoteStylesheets: false,
|
|
30
|
+
extraCss: css
|
|
25
31
|
});
|
|
26
|
-
const classes =
|
|
32
|
+
const classes = css.match(/\.([a-zA-Z0-9-_]+)/g)?.map((c) => c.replace(".", ""));
|
|
27
33
|
if (classes)
|
|
28
34
|
html = html.replace(new RegExp(`class="(${classes.join("|")})"`, "g"), "");
|
|
29
35
|
island.html = html;
|
|
36
|
+
return true;
|
|
30
37
|
}
|
|
31
|
-
return
|
|
38
|
+
return false;
|
|
32
39
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHeadCore } from "@unhead/vue";
|
|
2
2
|
import { renderSSRHead } from "@unhead/ssr";
|
|
3
|
-
import { useOgImageRuntimeConfig } from "../../utils.mjs";
|
|
3
|
+
import { normaliseFontInput, useOgImageRuntimeConfig } from "../../utils.mjs";
|
|
4
4
|
import { applyEmojis } from "./applyEmojis.mjs";
|
|
5
5
|
import { fetchIsland } from "./fetchIsland.mjs";
|
|
6
6
|
import { theme } from "#nuxt-og-image/unocss-config.mjs";
|
|
@@ -11,7 +11,8 @@ export async function devIframeTemplate(ctx) {
|
|
|
11
11
|
const head = createHeadCore();
|
|
12
12
|
head.push(island.head);
|
|
13
13
|
let defaultFontFamily = "sans-serif";
|
|
14
|
-
const
|
|
14
|
+
const normalisedFonts = normaliseFontInput([...options.fonts || [], ...fonts]);
|
|
15
|
+
const firstFont = normalisedFonts[0];
|
|
15
16
|
if (firstFont)
|
|
16
17
|
defaultFontFamily = firstFont.name;
|
|
17
18
|
await applyEmojis(ctx, island);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { OgImageOptions } from '../../types';
|
|
2
|
+
export declare function htmlDecodeQuotes(html: string): string;
|
|
2
3
|
export declare function decodeHtml(html: string): string;
|
|
3
4
|
export declare function extractAndNormaliseOgImageOptions(html: string): OgImageOptions | false;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export function htmlDecodeQuotes(html) {
|
|
2
|
+
return html.replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'");
|
|
3
|
+
}
|
|
1
4
|
export function decodeHtml(html) {
|
|
2
5
|
return html.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/¢/g, "\xA2").replace(/£/g, "\xA3").replace(/¥/g, "\xA5").replace(/€/g, "\u20AC").replace(/©/g, "\xA9").replace(/®/g, "\xAE").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(///g, "/").replace(/&#([0-9]+);/g, (full, int) => {
|
|
3
6
|
return String.fromCharCode(Number.parseInt(int));
|
|
@@ -28,6 +31,12 @@ export function extractAndNormaliseOgImageOptions(html) {
|
|
|
28
31
|
}
|
|
29
32
|
if (!options)
|
|
30
33
|
return false;
|
|
34
|
+
const description = html.match(/<meta[^>]+name="description"[^>]*>/)?.[0];
|
|
35
|
+
if (description) {
|
|
36
|
+
const [, content] = description.match(/content="([^"]+)"/) || [];
|
|
37
|
+
if (content && !options.props.description)
|
|
38
|
+
options.props.description = content;
|
|
39
|
+
}
|
|
31
40
|
const payload = decodeObjectHtmlEntities(options);
|
|
32
41
|
if (import.meta.dev) {
|
|
33
42
|
const socialPreview = {};
|
|
@@ -7,10 +7,10 @@ import { useResvg, useSatori, useSharp } from "./instances.mjs";
|
|
|
7
7
|
import { theme } from "#nuxt-og-image/unocss-config.mjs";
|
|
8
8
|
export async function createSvg(event) {
|
|
9
9
|
const { options } = event;
|
|
10
|
-
const { fonts, satoriOptions } = useOgImageRuntimeConfig();
|
|
10
|
+
const { fonts, satoriOptions: _satoriOptions } = useOgImageRuntimeConfig();
|
|
11
11
|
const vnodes = await createVNodes(event);
|
|
12
12
|
await event._nitro.hooks.callHook("nuxt-og-image:satori:vnodes", vnodes, event);
|
|
13
|
-
const normalisedFonts = normaliseFontInput([...
|
|
13
|
+
const normalisedFonts = normaliseFontInput([...event.options.fonts || [], ...fonts]);
|
|
14
14
|
const localFontPromises = [];
|
|
15
15
|
const preloadedFonts = [];
|
|
16
16
|
for (const font of normalisedFonts) {
|
|
@@ -30,15 +30,16 @@ export async function createSvg(event) {
|
|
|
30
30
|
}
|
|
31
31
|
const awaitedFonts = await Promise.all(localFontPromises);
|
|
32
32
|
const satori = await useSatori();
|
|
33
|
-
|
|
33
|
+
const satoriOptions = defu(options.satori, _satoriOptions, {
|
|
34
34
|
fonts: [...preloadedFonts, ...awaitedFonts].map((_f) => {
|
|
35
|
-
return {
|
|
35
|
+
return { name: _f.name, data: _f.data, style: _f.style, weight: Number(_f.weight) };
|
|
36
36
|
}),
|
|
37
37
|
tailwindConfig: { theme },
|
|
38
38
|
embedFont: true,
|
|
39
39
|
width: options.width,
|
|
40
40
|
height: options.height
|
|
41
|
-
})
|
|
41
|
+
});
|
|
42
|
+
return satori(vnodes, satoriOptions);
|
|
42
43
|
}
|
|
43
44
|
async function createPng(event) {
|
|
44
45
|
const { resvgOptions } = useOgImageRuntimeConfig();
|
|
@@ -28,5 +28,6 @@ export async function useSharp() {
|
|
|
28
28
|
}
|
|
29
29
|
export async function useCssInline() {
|
|
30
30
|
cssInlineInstance.instance = cssInlineInstance.instance || await import("#nuxt-og-image/bindings/css-inline").then((m) => m.default);
|
|
31
|
-
|
|
31
|
+
await cssInlineInstance.instance.initWasmPromise;
|
|
32
|
+
return cssInlineInstance.instance.cssInline;
|
|
32
33
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { defineSatoriTransformer } from "../utils.mjs";
|
|
2
2
|
import { decodeHtml } from "../../../options/extract.mjs";
|
|
3
|
-
export default defineSatoriTransformer(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
node
|
|
3
|
+
export default defineSatoriTransformer([
|
|
4
|
+
// clean up
|
|
5
|
+
{
|
|
6
|
+
filter: (node) => node.props?.["data-v-inspector"],
|
|
7
|
+
transform: async (node) => {
|
|
8
|
+
delete node.props["data-v-inspector"];
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
filter: (node) => typeof node.props?.children === "string",
|
|
13
|
+
transform: async (node) => {
|
|
14
|
+
node.props.children = decodeHtml(node.props.children);
|
|
15
|
+
}
|
|
7
16
|
}
|
|
8
|
-
|
|
17
|
+
]);
|
|
@@ -8,55 +8,54 @@ import { useNitroOrigin } from "#imports";
|
|
|
8
8
|
export default defineSatoriTransformer([
|
|
9
9
|
// fix <img src="">
|
|
10
10
|
{
|
|
11
|
-
filter: (node) => node.type === "img",
|
|
11
|
+
filter: (node) => node.type === "img" && node.props?.src,
|
|
12
12
|
transform: async (node, { e }) => {
|
|
13
|
-
const src = node.props
|
|
14
|
-
const isRelative = src
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let imageBuffer;
|
|
19
|
-
let valid = true;
|
|
13
|
+
const src = node.props.src;
|
|
14
|
+
const isRelative = src.startsWith("/");
|
|
15
|
+
let dimensions;
|
|
16
|
+
let imageBuffer;
|
|
17
|
+
if (isRelative) {
|
|
20
18
|
if (import.meta.prerender || import.meta.dev) {
|
|
21
19
|
const key = `root:public${src.replace("./", ":").replace("/", ":")}`;
|
|
22
|
-
if (await useStorage().hasItem(key))
|
|
20
|
+
if (await useStorage().hasItem(key))
|
|
23
21
|
imageBuffer = await useStorage().getItemRaw(key);
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (!import.meta.prerender && !updated) {
|
|
22
|
+
} else {
|
|
28
23
|
imageBuffer = await e.$fetch(src, {
|
|
29
24
|
baseURL: useNitroOrigin(e),
|
|
30
25
|
responseType: "arrayBuffer"
|
|
31
26
|
}).catch(() => {
|
|
32
|
-
valid = false;
|
|
33
27
|
});
|
|
34
|
-
valid = !!imageBuffer;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
node.props.width = Math.round(node.props.height * naturalAspectRatio);
|
|
51
|
-
} else if (!node.props.width && !node.props.height) {
|
|
52
|
-
node.props.width = dimensions.width;
|
|
53
|
-
node.props.height = dimensions.height;
|
|
54
|
-
}
|
|
29
|
+
} else {
|
|
30
|
+
imageBuffer = await $fetch(src, {
|
|
31
|
+
responseType: "arrayBuffer"
|
|
32
|
+
}).catch(() => {
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (imageBuffer)
|
|
36
|
+
imageBuffer = Buffer.from(imageBuffer);
|
|
37
|
+
if (imageBuffer) {
|
|
38
|
+
node.props.src = toBase64Image(src, imageBuffer);
|
|
39
|
+
try {
|
|
40
|
+
const imageSize = sizeOf(imageBuffer);
|
|
41
|
+
dimensions = { width: imageSize.width, height: imageSize.height };
|
|
42
|
+
} catch (e2) {
|
|
55
43
|
}
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
}
|
|
45
|
+
if (dimensions?.width && dimensions?.height) {
|
|
46
|
+
const naturalAspectRatio = dimensions.width / dimensions.height;
|
|
47
|
+
if (node.props.width && !node.props.height) {
|
|
48
|
+
node.props.height = Math.round(node.props.width / naturalAspectRatio);
|
|
49
|
+
} else if (node.props.height && !node.props.width) {
|
|
50
|
+
node.props.width = Math.round(node.props.height * naturalAspectRatio);
|
|
51
|
+
} else if (!node.props.width && !node.props.height) {
|
|
52
|
+
node.props.width = dimensions.width;
|
|
53
|
+
node.props.height = dimensions.height;
|
|
58
54
|
}
|
|
59
55
|
}
|
|
56
|
+
if (node.props.src.startsWith("/")) {
|
|
57
|
+
node.props.src = `${withBase(src, `${useNitroOrigin(e)}`)}?${Date.now()}`;
|
|
58
|
+
}
|
|
60
59
|
}
|
|
61
60
|
},
|
|
62
61
|
// fix style="background-image: url('')"
|
|
@@ -64,11 +63,21 @@ export default defineSatoriTransformer([
|
|
|
64
63
|
filter: (node) => node.props?.style?.backgroundImage?.includes("url("),
|
|
65
64
|
transform: async (node, { e }) => {
|
|
66
65
|
const backgroundImage = node.props.style.backgroundImage;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
66
|
+
const src = backgroundImage.replace(/^url\(['"]?/, "").replace(/['"]?\)$/, "");
|
|
67
|
+
const isRelative = src?.startsWith("/");
|
|
68
|
+
if (isRelative) {
|
|
69
|
+
if (import.meta.prerender || import.meta.dev) {
|
|
70
|
+
const key = `root:public${src.replace("./", ":").replace("/", ":")}`;
|
|
71
|
+
if (await useStorage().hasItem(key)) {
|
|
72
|
+
const imageBuffer = await useStorage().getItemRaw(key);
|
|
73
|
+
if (imageBuffer) {
|
|
74
|
+
const base64 = toBase64Image(src, Buffer.from(imageBuffer));
|
|
75
|
+
node.props.style.backgroundImage = `url(${base64})`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
71
79
|
node.props.style.backgroundImage = `url(${withBase(src, `${useNitroOrigin(e)}`)}?${Date.now()})`;
|
|
80
|
+
}
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
}
|
|
@@ -2,6 +2,7 @@ import { html as convertHtmlToSatori } from "satori-html";
|
|
|
2
2
|
import { fetchIsland } from "../../html/fetchIsland.mjs";
|
|
3
3
|
import { applyInlineCss } from "../../html/applyInlineCss.mjs";
|
|
4
4
|
import { applyEmojis } from "../../html/applyEmojis.mjs";
|
|
5
|
+
import { htmlDecodeQuotes } from "../../options/extract.mjs";
|
|
5
6
|
import { walkSatoriTree } from "./utils.mjs";
|
|
6
7
|
import unocss from "./plugins/unocss.mjs";
|
|
7
8
|
import emojis from "./plugins/emojis.mjs";
|
|
@@ -13,11 +14,12 @@ export async function createVNodes(ctx) {
|
|
|
13
14
|
let html = ctx.options.html;
|
|
14
15
|
if (!html) {
|
|
15
16
|
const island = await fetchIsland(ctx);
|
|
17
|
+
island.html = htmlDecodeQuotes(island.html);
|
|
16
18
|
await applyInlineCss(ctx, island);
|
|
17
19
|
await applyEmojis(ctx, island);
|
|
18
20
|
html = island.html;
|
|
19
21
|
}
|
|
20
|
-
const template = `<div
|
|
22
|
+
const template = `<div style="position: relative; display: flex; margin: 0 auto; width: ${ctx.options.width}px; height: ${ctx.options.height}px; overflow: hidden;">${html}</div>`;
|
|
21
23
|
const satoriTree = convertHtmlToSatori(template);
|
|
22
24
|
await walkSatoriTree(ctx, satoriTree, [
|
|
23
25
|
unocss,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { parseURL, withQuery,
|
|
1
|
+
import { parseURL, withQuery, withoutTrailingSlash } from "ufo";
|
|
2
2
|
import { createError, getQuery } from "h3";
|
|
3
3
|
import { defu } from "defu";
|
|
4
|
-
import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
5
4
|
import { fetchPathHtmlAndExtractOptions } from "../options/fetch.mjs";
|
|
6
5
|
import { prerenderOptionsCache } from "../cache/prerender.mjs";
|
|
7
6
|
import { useChromiumRenderer, useSatoriRenderer } from "../renderers/satori/instances.mjs";
|
|
8
7
|
import { separateProps, useOgImageRuntimeConfig } from "../../utils.mjs";
|
|
9
8
|
import { resolvePathCacheKey } from "../../nitro/utils.mjs";
|
|
10
|
-
import {
|
|
9
|
+
import { createNitroRouteRuleMatcher } from "../../nitro/kit.mjs";
|
|
10
|
+
import { useNitroApp } from "#internal/nitro/app";
|
|
11
11
|
export async function resolveRendererContext(e) {
|
|
12
12
|
const runtimeConfig = useOgImageRuntimeConfig();
|
|
13
13
|
const path = parseURL(e.path).pathname;
|
|
@@ -46,12 +46,8 @@ export async function resolveRendererContext(e) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
delete queryParams.options;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
const routeRules = defu({}, ..._routeRulesMatcher.matchAll(
|
|
53
|
-
withoutBase(basePath.split("?")[0], useRuntimeConfig().app.baseURL)
|
|
54
|
-
).reverse());
|
|
49
|
+
const routeRuleMatcher = createNitroRouteRuleMatcher();
|
|
50
|
+
const routeRules = routeRuleMatcher(basePath);
|
|
55
51
|
if (typeof routeRules.ogImage === "undefined" && !options) {
|
|
56
52
|
return createError({
|
|
57
53
|
statusCode: 400,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
2
|
+
import { defu } from "defu";
|
|
3
|
+
import { withoutBase, withoutTrailingSlash } from "ufo";
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
export function withoutQuery(path) {
|
|
6
|
+
return path.split("?")[0];
|
|
7
|
+
}
|
|
8
|
+
export function createNitroRouteRuleMatcher() {
|
|
9
|
+
const { nitro, app } = useRuntimeConfig();
|
|
10
|
+
const _routeRulesMatcher = toRouteMatcher(
|
|
11
|
+
createRadixRouter({
|
|
12
|
+
routes: Object.fromEntries(
|
|
13
|
+
Object.entries(nitro?.routeRules || {}).map(([path, rules]) => [withoutTrailingSlash(path), rules])
|
|
14
|
+
)
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
return (path) => {
|
|
18
|
+
return defu({}, ..._routeRulesMatcher.matchAll(
|
|
19
|
+
// radix3 does not support trailing slashes
|
|
20
|
+
withoutBase(withoutTrailingSlash(withoutQuery(path)), app.baseURL)
|
|
21
|
+
).reverse());
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -2,14 +2,17 @@ import { defineNitroPlugin } from "nitropack/dist/runtime/plugin";
|
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { getOgImagePath, useOgImageRuntimeConfig } from "../../utils.mjs";
|
|
4
4
|
export default defineNitroPlugin((nitroApp) => {
|
|
5
|
+
const { isNuxtContentDocumentDriven, defaults } = useOgImageRuntimeConfig();
|
|
5
6
|
nitroApp.hooks.hook("content:file:afterParse", async (content) => {
|
|
6
7
|
if (content._draft || content._extension !== "md" || content._partial || content.indexable === false || content.index === false)
|
|
7
8
|
return;
|
|
8
|
-
|
|
9
|
+
let path = content.path;
|
|
10
|
+
if (isNuxtContentDocumentDriven)
|
|
11
|
+
path = content._path;
|
|
12
|
+
if (path && content.ogImage) {
|
|
9
13
|
const ogImageConfig = typeof content.ogImage === "object" ? content.ogImage : {};
|
|
10
|
-
const { defaults } = useOgImageRuntimeConfig();
|
|
11
14
|
const optionsWithDefault = defu(ogImageConfig, defaults);
|
|
12
|
-
const src = getOgImagePath(
|
|
15
|
+
const src = getOgImagePath(path, optionsWithDefault);
|
|
13
16
|
const payload = {
|
|
14
17
|
title: content.title,
|
|
15
18
|
excerpt: content.description || content.excerpt,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("nitropack").NitroAppPlugin;
|
|
1
|
+
declare const _default: import("nitropack/dist/runtime/plugin").NitroAppPlugin;
|
|
2
2
|
export default _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { parseURL
|
|
1
|
+
import { parseURL } from "ufo";
|
|
2
2
|
import { defineNitroPlugin } from "nitropack/dist/runtime/plugin";
|
|
3
|
-
import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
4
|
-
import { defu } from "defu";
|
|
5
3
|
import { extractAndNormaliseOgImageOptions } from "../../core/options/extract.mjs";
|
|
6
4
|
import { prerenderOptionsCache } from "../../core/cache/prerender.mjs";
|
|
7
5
|
import { isInternalRoute } from "../../utils.pure.mjs";
|
|
8
6
|
import { resolvePathCacheKey } from "../utils.mjs";
|
|
9
|
-
import {
|
|
7
|
+
import { createNitroRouteRuleMatcher } from "../kit.mjs";
|
|
10
8
|
export default defineNitroPlugin(async (nitro) => {
|
|
11
9
|
if (!import.meta.prerender)
|
|
12
10
|
return;
|
|
@@ -15,14 +13,9 @@ export default defineNitroPlugin(async (nitro) => {
|
|
|
15
13
|
const path = parseURL(ctx.event.path).pathname;
|
|
16
14
|
if (isInternalRoute(path))
|
|
17
15
|
return;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
const routeRules = defu({}, ..._routeRulesMatcher.matchAll(
|
|
23
|
-
withoutBase(path.split("?")[0], runtimeConfig.app.baseURL)
|
|
24
|
-
).reverse()).ogImage;
|
|
25
|
-
if (routeRules === false)
|
|
16
|
+
const routeRuleMatcher = createNitroRouteRuleMatcher();
|
|
17
|
+
const routeRules = routeRuleMatcher(path);
|
|
18
|
+
if (routeRules.ogImage === false)
|
|
26
19
|
return;
|
|
27
20
|
const options = extractAndNormaliseOgImageOptions([
|
|
28
21
|
head.join("\n"),
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { defineEventHandler, setHeader } from "h3";
|
|
2
2
|
import { useOgImageRuntimeConfig } from "../../../utils.mjs";
|
|
3
|
-
import { useSiteConfig } from "#imports";
|
|
4
3
|
import compatibility from "#nuxt-og-image/compatibility";
|
|
5
4
|
import { componentNames } from "#nuxt-og-image/component-names.mjs";
|
|
6
5
|
export default defineEventHandler(async (e) => {
|
|
7
6
|
setHeader(e, "Content-Type", "application/json");
|
|
8
7
|
const runtimeConfig = useOgImageRuntimeConfig();
|
|
9
|
-
const siteConfig = await useSiteConfig(e, { debug: true });
|
|
10
8
|
return {
|
|
11
|
-
siteConfigUrl: {
|
|
12
|
-
value: siteConfig.url,
|
|
13
|
-
source: siteConfig._context.url || "unknown"
|
|
14
|
-
},
|
|
15
9
|
componentNames,
|
|
16
10
|
runtimeConfig,
|
|
17
11
|
compatibility
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createError, defineEventHandler, getQuery, proxyRequest, sendRedirect, setHeader } from "h3";
|
|
2
|
+
import { parseURL } from "ufo";
|
|
3
|
+
import { getExtension, normaliseFontInput, useOgImageRuntimeConfig } from "../../../utils.mjs";
|
|
4
|
+
import { assets } from "#internal/nitro/virtual/server-assets";
|
|
5
|
+
export default defineEventHandler(async (e) => {
|
|
6
|
+
const path = parseURL(e.path).pathname;
|
|
7
|
+
const [_name, _weight] = path.split("/font/")[1].split(".")[0].split("/");
|
|
8
|
+
if (!_name || !_weight)
|
|
9
|
+
return "Provide a font name and weight";
|
|
10
|
+
const name = _name[0].toUpperCase() + _name.slice(1);
|
|
11
|
+
const weight = Math.round(Number.parseInt(_weight) / 100) * 100;
|
|
12
|
+
const config = useOgImageRuntimeConfig();
|
|
13
|
+
const normalisedFonts = normaliseFontInput(config.fonts);
|
|
14
|
+
let font;
|
|
15
|
+
if (typeof getQuery(e).font === "string")
|
|
16
|
+
font = JSON.parse(getQuery(e).font);
|
|
17
|
+
if (!font) {
|
|
18
|
+
font = normalisedFonts.find((font2) => {
|
|
19
|
+
return font2.name.toLowerCase() === name.toLowerCase() && weight === Number(font2.weight);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (!font) {
|
|
23
|
+
return createError({
|
|
24
|
+
statusCode: 404,
|
|
25
|
+
statusMessage: `[Nuxt OG Image] Font ${name}:${weight} not found`
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (import.meta.dev || import.meta.prerender) {
|
|
29
|
+
if (font.key && await assets.hasItem(font.key)) {
|
|
30
|
+
setHeader(e, "Content-Type", `font/${getExtension(font.path)}`);
|
|
31
|
+
return assets.getItemRaw(font.key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const css = await globalThis.$fetch(`https://fonts.googleapis.com/css2?family=${name}:wght@${weight}`, {
|
|
35
|
+
headers: {
|
|
36
|
+
// Make sure it returns TTF.
|
|
37
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (!css) {
|
|
41
|
+
return createError({
|
|
42
|
+
statusCode: 500,
|
|
43
|
+
statusMessage: `[Nuxt OG Image] Invalid Google Font ${name}:${weight}`
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const ttfResource = css.match(/src: url\((.+)\) format\('(opentype|truetype)'\)/);
|
|
47
|
+
if (ttfResource?.[1])
|
|
48
|
+
return proxyRequest(e, ttfResource[1], {});
|
|
49
|
+
const woff2Resource = css.match(/src: url\((.+)\) format\('woff2'\)/);
|
|
50
|
+
if (woff2Resource?.[1])
|
|
51
|
+
return sendRedirect(e, woff2Resource[1]);
|
|
52
|
+
return createError({
|
|
53
|
+
statusCode: 500,
|
|
54
|
+
statusMessage: `[Nuxt OG Image] Malformed Google Font CSS ${css}`
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -5,7 +5,6 @@ import { devIframeTemplate } from "../../../core/html/devIframeTemplate.mjs";
|
|
|
5
5
|
import { applyInlineCss } from "../../../core/html/applyInlineCss.mjs";
|
|
6
6
|
import { useOgImageBufferCache } from "../../../cache.mjs";
|
|
7
7
|
import { useOgImageRuntimeConfig } from "../../../utils.mjs";
|
|
8
|
-
import { useSiteConfig } from "#imports";
|
|
9
8
|
export default defineEventHandler(async (e) => {
|
|
10
9
|
const ctx = await resolveRendererContext(e);
|
|
11
10
|
if (ctx instanceof H3Error)
|
|
@@ -20,13 +19,15 @@ export default defineEventHandler(async (e) => {
|
|
|
20
19
|
if (options.renderer === "chromium")
|
|
21
20
|
compatibilityHints.push("Using Chromium to generate images is only supported in Node based environments. It's recommended to only use this if you're prerendering");
|
|
22
21
|
if (options.component !== "PageScreenshot" && await applyInlineCss(ctx, await fetchIsland(ctx)))
|
|
23
|
-
compatibilityHints.push("Inlining CSS is
|
|
22
|
+
compatibilityHints.push("Inlining CSS is not supported on Cloudflare.");
|
|
24
23
|
setHeader(e, "Content-Type", "application/json");
|
|
25
24
|
return {
|
|
25
|
+
siteConfig: {
|
|
26
|
+
url: e.context.siteConfig.get().url
|
|
27
|
+
},
|
|
26
28
|
compatibilityHints,
|
|
27
29
|
cacheKey: ctx.key,
|
|
28
30
|
options: ctx.options,
|
|
29
|
-
siteConfig: useSiteConfig(e),
|
|
30
31
|
...options.renderer === "satori" ? await renderer.debug(ctx) : void 0
|
|
31
32
|
};
|
|
32
33
|
}
|
|
@@ -2,9 +2,8 @@ import { withoutLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
|
2
2
|
import { hash } from "ohash";
|
|
3
3
|
import { normalizeKey } from "unstorage";
|
|
4
4
|
import { getQuery } from "h3";
|
|
5
|
-
import { useSiteConfig } from "#imports";
|
|
6
5
|
export function resolvePathCacheKey(e, path) {
|
|
7
|
-
const siteConfig =
|
|
6
|
+
const siteConfig = e.context.siteConfig.get();
|
|
8
7
|
const basePath = withoutTrailingSlash(withoutLeadingSlash(normalizeKey(path || e.path)));
|
|
9
8
|
return [
|
|
10
9
|
!basePath || basePath === "/" ? "index" : basePath,
|
|
@@ -15,11 +15,18 @@ export default defineNuxtPlugin({
|
|
|
15
15
|
key: "nuxt-og-image:overrides-and-canonical-urls",
|
|
16
16
|
hooks: {
|
|
17
17
|
"tags:resolve": async (ctx2) => {
|
|
18
|
+
const hasPrimaryPayload = ctx2.tags.some((tag) => tag.tag === "script" && tag.props.id === "nuxt-og-image-options");
|
|
18
19
|
let overrides;
|
|
19
20
|
for (const tag of ctx2.tags) {
|
|
20
21
|
if (tag.tag === "script" && tag.props.id === "nuxt-og-image-overrides") {
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
if (hasPrimaryPayload) {
|
|
23
|
+
overrides = separateProps(JSON.parse(tag.innerHTML || "{}"));
|
|
24
|
+
delete ctx2.tags[ctx2.tags.indexOf(tag)];
|
|
25
|
+
} else {
|
|
26
|
+
tag.props.id = "nuxt-og-image-options";
|
|
27
|
+
tag.innerHTML = JSON.stringify(separateProps(JSON.parse(tag.innerHTML || "{}")));
|
|
28
|
+
tag._d = "script:id:nuxt-og-image-options";
|
|
29
|
+
}
|
|
23
30
|
break;
|
|
24
31
|
}
|
|
25
32
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { DefineOgImageInput, OgImageOptions, OgImagePrebuilt } from '../types';
|
|
2
|
-
|
|
2
|
+
import type { NuxtSSRContext } from '#app';
|
|
3
|
+
export declare function createOgImageMeta(src: string | null, input: OgImageOptions | OgImagePrebuilt, resolvedOptions: OgImageOptions, ssrContext: NuxtSSRContext): void;
|
|
3
4
|
export declare function normaliseOptions(_options: DefineOgImageInput): OgImageOptions | OgImagePrebuilt;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
2
|
import { withQuery } from "ufo";
|
|
3
|
-
import { separateProps } from "../utils.mjs";
|
|
3
|
+
import { getExtension, separateProps } from "../utils.mjs";
|
|
4
4
|
import { unref, useServerHead } from "#imports";
|
|
5
5
|
import { componentNames } from "#build/nuxt-og-image/components.mjs";
|
|
6
6
|
export function createOgImageMeta(src, input, resolvedOptions, ssrContext) {
|
|
7
7
|
const _input = separateProps(defu(input, ssrContext._ogImagePayload));
|
|
8
8
|
let url = src || input.url || resolvedOptions.url;
|
|
9
|
-
if (
|
|
9
|
+
if (!url)
|
|
10
|
+
return;
|
|
11
|
+
if (input._query && Object.keys(input._query).length && url)
|
|
10
12
|
url = withQuery(url, { _query: input._query });
|
|
11
|
-
let urlExtension = (url
|
|
13
|
+
let urlExtension = getExtension(url) || resolvedOptions.extension;
|
|
12
14
|
if (urlExtension === "jpg")
|
|
13
15
|
urlExtension = "jpeg";
|
|
14
16
|
const meta = [
|