nuxt-og-image 2.1.3 → 2.2.2
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/dist/client/200.html +5 -5
- package/dist/client/404.html +5 -5
- package/dist/client/_nuxt/IconCSS.d1d053b9.js +1 -0
- package/dist/client/_nuxt/IconCSS.e3ab0ef2.css +1 -0
- package/dist/client/_nuxt/{ImageLoader.dc25aae4.js → ImageLoader.00a03ea3.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -0
- package/dist/client/_nuxt/builds/meta/951f430d-b168-4ba1-8f9a-77e148e2fb60.json +1 -0
- package/dist/client/_nuxt/{entry.ffee29d2.css → entry.1cf2564c.css} +1 -1
- package/dist/client/_nuxt/entry.d03a462f.js +135 -0
- package/dist/client/_nuxt/{error-404.03584591.js → error-404.ad1f3aae.js} +1 -1
- package/dist/client/_nuxt/{error-500.0269b959.js → error-500.745ad9c5.js} +1 -1
- package/dist/client/_nuxt/{index.6c1db53d.js → index.9c8984b5.js} +1 -1
- package/dist/client/_nuxt/{options.0b48d67b.js → options.db552670.js} +1 -1
- package/dist/client/_nuxt/{png.b1d21a11.js → png.98e13123.js} +1 -1
- package/dist/client/_nuxt/{shiki.70038c40.js → shiki.806984be.js} +1 -1
- package/dist/client/_nuxt/{svg.5a8d996c.js → svg.a002e3e4.js} +1 -1
- package/dist/client/_nuxt/{vnodes.c7225cfc.js → vnodes.4f3ec43d.js} +1 -1
- package/dist/client/index.html +5 -5
- package/dist/client/options/index.html +5 -5
- package/dist/client/png/index.html +5 -5
- package/dist/client/svg/index.html +5 -5
- package/dist/client/vnodes/index.html +5 -5
- package/dist/module.d.mts +7 -0
- package/dist/module.d.ts +7 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/composables/defineOgImage.d.ts +5 -1
- package/dist/runtime/composables/defineOgImage.mjs +25 -2
- package/dist/runtime/nitro/middleware/og.png.mjs +2 -2
- package/dist/runtime/nitro/renderers/browser.mjs +9 -5
- package/dist/runtime/nitro/renderers/satori/index.mjs +2 -2
- package/dist/runtime/nitro/routes/html.mjs +8 -2
- package/dist/runtime/nitro/utils.mjs +1 -1
- package/dist/runtime/public-assets-optional/resvg/resvg.wasm +0 -0
- package/dist/runtime/types.d.ts +7 -0
- package/package.json +18 -17
- package/dist/client/_nuxt/IconCSS.3e8abf01.js +0 -1
- package/dist/client/_nuxt/IconCSS.940a18a7.css +0 -1
- package/dist/client/_nuxt/entry.e59cdd76.js +0 -135
|
@@ -20,7 +20,7 @@ export function defineOgImageStatic(options = {}) {
|
|
|
20
20
|
export function defineOgImageCached(options = {}) {
|
|
21
21
|
const { defaults } = useRuntimeConfig()["nuxt-og-image"];
|
|
22
22
|
if (!defaults.cacheTtl && !options.cacheTtl)
|
|
23
|
-
options.cacheTtl = 60 * 60 * 24 * 7;
|
|
23
|
+
options.cacheTtl = 60 * 60 * 24 * 1e3 * 7;
|
|
24
24
|
return defineOgImage({
|
|
25
25
|
cache: true,
|
|
26
26
|
...options
|
|
@@ -37,7 +37,30 @@ export function defineOgImageDynamic(options = {}) {
|
|
|
37
37
|
return defineOgImageWithoutCache(options);
|
|
38
38
|
}
|
|
39
39
|
export async function defineOgImage(_options = {}) {
|
|
40
|
-
if (
|
|
40
|
+
if (import.meta.server) {
|
|
41
|
+
if (_options.url) {
|
|
42
|
+
const type = _options.url.endsWith(".png") ? "image/png" : "image/jpeg";
|
|
43
|
+
const meta2 = [
|
|
44
|
+
{ property: "og:image", content: _options.url },
|
|
45
|
+
{ property: "og:image:type", content: type },
|
|
46
|
+
{ name: "twitter:card", content: "summary_large_image" },
|
|
47
|
+
{ name: "twitter:image:src", content: _options.url }
|
|
48
|
+
];
|
|
49
|
+
if (_options.width) {
|
|
50
|
+
meta2.push({ property: "og:image:width", content: _options.width });
|
|
51
|
+
meta2.push({ name: "twitter:image:width", content: _options.width });
|
|
52
|
+
}
|
|
53
|
+
if (_options.height) {
|
|
54
|
+
meta2.push({ property: "og:image:height", content: _options.height });
|
|
55
|
+
meta2.push({ name: "twitter:image:height", content: _options.height });
|
|
56
|
+
}
|
|
57
|
+
if (_options.alt) {
|
|
58
|
+
meta2.push({ property: "og:image:alt", content: _options.alt });
|
|
59
|
+
meta2.push({ name: "twitter:image:alt", content: _options.alt });
|
|
60
|
+
}
|
|
61
|
+
useServerHead({ meta: meta2 });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
41
64
|
const { defaults } = useRuntimeConfig()["nuxt-og-image"];
|
|
42
65
|
const options = normaliseOgImageOptions(_options);
|
|
43
66
|
const optionsWithDefault = defu(options, defaults);
|
|
@@ -52,8 +52,8 @@ export default defineEventHandler(async (e) => {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
if (png) {
|
|
55
|
-
if (cacheEnabled) {
|
|
56
|
-
setHeader(e, "Cache-Control",
|
|
55
|
+
if (cacheEnabled && options.cacheTtl) {
|
|
56
|
+
setHeader(e, "Cache-Control", `public, max-age=${Math.round(options.cacheTtl / 1e3)}`);
|
|
57
57
|
} else {
|
|
58
58
|
setHeader(e, "Cache-Control", "no-cache, no-store, must-revalidate");
|
|
59
59
|
setHeader(e, "Pragma", "no-cache");
|
|
@@ -17,11 +17,15 @@ const BrowserRenderer = {
|
|
|
17
17
|
let res = null;
|
|
18
18
|
if (browser) {
|
|
19
19
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
if (options.html) {
|
|
21
|
+
res = await screenshot(browser, options);
|
|
22
|
+
} else {
|
|
23
|
+
res = await screenshot(browser, {
|
|
24
|
+
...options,
|
|
25
|
+
host: options.requestOrigin,
|
|
26
|
+
path: `/api/og-image-html?path=${options.path}`
|
|
27
|
+
});
|
|
28
|
+
}
|
|
25
29
|
} finally {
|
|
26
30
|
await browser.close();
|
|
27
31
|
}
|
|
@@ -23,13 +23,13 @@ const SatoriRenderer = {
|
|
|
23
23
|
return pngCreator(svg, options);
|
|
24
24
|
},
|
|
25
25
|
createVNode: async function createVNode(options) {
|
|
26
|
-
const html = await globalThis.$fetch("/api/og-image-html", {
|
|
26
|
+
const html = options.html || await globalThis.$fetch("/api/og-image-html", {
|
|
27
27
|
params: {
|
|
28
28
|
path: options.path,
|
|
29
29
|
options: JSON.stringify(options)
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
const body = html.match(/<body[^>]*>([\s\S]*)<\/body>/)?.[1] ||
|
|
32
|
+
const body = html.match(/<body[^>]*>([\s\S]*)<\/body>/)?.[1] || html;
|
|
33
33
|
const satoriTree = convertHtmlToSatori(body);
|
|
34
34
|
await walkSatoriTree(satoriTree, [
|
|
35
35
|
emojis,
|
|
@@ -59,6 +59,12 @@ export default defineEventHandler(async (e) => {
|
|
|
59
59
|
});
|
|
60
60
|
} catch (e2) {
|
|
61
61
|
}
|
|
62
|
+
const googleFonts = {};
|
|
63
|
+
fonts.filter((font) => !font.path).forEach((font) => {
|
|
64
|
+
if (!googleFonts[font.name])
|
|
65
|
+
googleFonts[font.name] = [];
|
|
66
|
+
googleFonts[font.name].push(font);
|
|
67
|
+
});
|
|
62
68
|
head.push({
|
|
63
69
|
style: [
|
|
64
70
|
{
|
|
@@ -119,9 +125,9 @@ img.emoji {
|
|
|
119
125
|
rel: "stylesheet"
|
|
120
126
|
},
|
|
121
127
|
// have to add each weight as their own stylesheet
|
|
122
|
-
...
|
|
128
|
+
...Object.entries(googleFonts).map(([name, fonts2]) => {
|
|
123
129
|
return {
|
|
124
|
-
href: `https://fonts.googleapis.com/css2?family=${
|
|
130
|
+
href: `https://fonts.googleapis.com/css2?family=${name}:wght@${fonts2.map((f) => f.weight).join(";")}&display=swap`,
|
|
125
131
|
rel: "stylesheet"
|
|
126
132
|
};
|
|
127
133
|
})
|
|
@@ -45,7 +45,7 @@ export async function fetchOptionsCached(e, path) {
|
|
|
45
45
|
].join(":");
|
|
46
46
|
const { cachedItem, update } = await useNitroCache(e, "nuxt-og-image", {
|
|
47
47
|
key,
|
|
48
|
-
// allow internal requests to be cached
|
|
48
|
+
// allow internal requests to be cached for 5 seconds
|
|
49
49
|
cacheTtl: 5 * 1e3,
|
|
50
50
|
cache: !process.dev,
|
|
51
51
|
headers: false
|
|
Binary file
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -25,12 +25,19 @@ export interface ScreenshotOptions {
|
|
|
25
25
|
}
|
|
26
26
|
export interface OgImageOptions extends Partial<ScreenshotOptions> {
|
|
27
27
|
provider?: 'browser' | 'satori';
|
|
28
|
+
/**
|
|
29
|
+
* Provide a static HTML template to render the OG Image instead of a component.
|
|
30
|
+
*/
|
|
31
|
+
html?: string;
|
|
28
32
|
title?: string;
|
|
29
33
|
description?: string;
|
|
30
34
|
component?: string | null;
|
|
31
35
|
alt?: string;
|
|
32
36
|
cache?: boolean;
|
|
33
37
|
cacheKey?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The time to live of the cache in milliseconds.
|
|
40
|
+
*/
|
|
34
41
|
cacheTtl?: number;
|
|
35
42
|
/**
|
|
36
43
|
* @deprecated Use `cache` instead
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-og-image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
5
|
-
"packageManager": "pnpm@8.9.
|
|
4
|
+
"version": "2.2.2",
|
|
5
|
+
"packageManager": "pnpm@8.9.2",
|
|
6
6
|
"description": "Enlightened OG Image generation for Nuxt.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@nuxt/kit": "^3.
|
|
31
|
-
"@resvg/resvg-js": "^2.
|
|
32
|
-
"@resvg/resvg-wasm": "^2.
|
|
33
|
-
"@
|
|
30
|
+
"@nuxt/kit": "^3.8.0",
|
|
31
|
+
"@resvg/resvg-js": "^2.6.0",
|
|
32
|
+
"@resvg/resvg-wasm": "^2.6.0",
|
|
33
|
+
"@twemoji/api": "^14.0.2",
|
|
34
|
+
"@types/fs-extra": "^11.0.3",
|
|
34
35
|
"birpc": "0.2.14",
|
|
35
36
|
"chalk": "^5.3.0",
|
|
36
37
|
"chrome-launcher": "^1.1.0",
|
|
37
38
|
"css-inline": "^0.11.0",
|
|
38
|
-
"defu": "^6.1.
|
|
39
|
+
"defu": "^6.1.3",
|
|
39
40
|
"execa": "^8.0.1",
|
|
40
41
|
"fast-glob": "^3.3.1",
|
|
41
42
|
"flatted": "^3.2.9",
|
|
@@ -43,8 +44,8 @@
|
|
|
43
44
|
"globby": "^13.2.2",
|
|
44
45
|
"image-size": "^1.0.2",
|
|
45
46
|
"launch-editor": "^2.6.1",
|
|
46
|
-
"nuxt-site-config": "^1.5.
|
|
47
|
-
"nuxt-site-config-kit": "^1.5.
|
|
47
|
+
"nuxt-site-config": "^1.5.5",
|
|
48
|
+
"nuxt-site-config-kit": "^1.5.5",
|
|
48
49
|
"nypm": "^0.3.3",
|
|
49
50
|
"ofetch": "^1.3.3",
|
|
50
51
|
"ohash": "^1.1.3",
|
|
@@ -64,19 +65,19 @@
|
|
|
64
65
|
"yoga-wasm-web": "^0.3.3"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"@antfu/eslint-config": "1.0.0-beta.
|
|
68
|
-
"@nuxt/devtools": "1.0.0
|
|
68
|
+
"@antfu/eslint-config": "1.0.0-beta.29",
|
|
69
|
+
"@nuxt/devtools": "1.0.0",
|
|
69
70
|
"@nuxt/module-builder": "^0.5.2",
|
|
70
|
-
"@nuxt/test-utils": "3.
|
|
71
|
+
"@nuxt/test-utils": "3.8.0",
|
|
71
72
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
72
|
-
"@types/ws": "^8.5.
|
|
73
|
+
"@types/ws": "^8.5.8",
|
|
73
74
|
"bumpp": "^9.2.0",
|
|
74
|
-
"eslint": "8.
|
|
75
|
+
"eslint": "8.52.0",
|
|
75
76
|
"jest-image-snapshot": "^6.2.0",
|
|
76
|
-
"nuxt": "^3.
|
|
77
|
-
"nuxt-icon": "
|
|
77
|
+
"nuxt": "^3.8.0",
|
|
78
|
+
"nuxt-icon": "0.6.1",
|
|
78
79
|
"playwright": "^1.39.0",
|
|
79
|
-
"sass": "^1.69.
|
|
80
|
+
"sass": "^1.69.5",
|
|
80
81
|
"vitest": "^0.34.6"
|
|
81
82
|
},
|
|
82
83
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as l,H as _,I as d,n as o,o as f,c as m,s as S,_ as g}from"./entry.e59cdd76.js";const x=l({__name:"IconCSS",props:{name:{type:String,required:!0},size:{type:String,default:""}},setup(r){const n=r;_(e=>({"77a740e2":u.value}));const s=d(),p=o(()=>{var e;return((((e=s.nuxtIcon)==null?void 0:e.aliases)||{})[n.name]||n.name).replace(/^i-/,"")}),u=o(()=>`url('https://api.iconify.design/${p.value.replace(":","/")}.svg')`),a=o(()=>{var t,c,i;if(!n.size&&typeof((t=s.nuxtIcon)==null?void 0:t.size)=="boolean"&&!((c=s.nuxtIcon)!=null&&c.size))return;const e=n.size||((i=s.nuxtIcon)==null?void 0:i.size)||"1em";return String(Number(e))===e?`${e}px`:e});return(e,t)=>(f(),m("span",{style:S({width:a.value,height:a.value})},null,4))}});const z=g(x,[["__scopeId","data-v-d83431fd"]]);export{z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
span[data-v-d83431fd]{background-color:currentColor;display:inline-block;-webkit-mask-image:var(--77a740e2);mask-image:var(--77a740e2);-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;vertical-align:middle}
|