nuxt-og-image 2.2.0 → 2.2.3
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.e3ab0ef2.css +1 -0
- package/dist/client/_nuxt/IconCSS.eb945f57.js +1 -0
- package/dist/client/_nuxt/{ImageLoader.6c3db107.js → ImageLoader.4e3865a8.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/d5b21f15-40fc-4b14-b673-c481e1c97b94.json +1 -0
- package/dist/client/_nuxt/{entry.067759ab.css → entry.1cf2564c.css} +1 -1
- package/dist/client/_nuxt/{entry.30bfbdb0.js → entry.3421d1a0.js} +49 -49
- package/dist/client/_nuxt/{error-404.f53be311.js → error-404.89fe8254.js} +1 -1
- package/dist/client/_nuxt/{error-500.95a4e96b.js → error-500.5cd69dc7.js} +1 -1
- package/dist/client/_nuxt/{index.b84d405c.js → index.c3e4ac0b.js} +1 -1
- package/dist/client/_nuxt/{options.ba272791.js → options.3bdb3c18.js} +1 -1
- package/dist/client/_nuxt/{png.7ba30b3a.js → png.ca36d04c.js} +1 -1
- package/dist/client/_nuxt/{shiki.92298145.js → shiki.c57f2365.js} +1 -1
- package/dist/client/_nuxt/{svg.be478a83.js → svg.f659bd92.js} +1 -1
- package/dist/client/_nuxt/{vnodes.7d9fa602.js → vnodes.2b126a87.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 +3 -0
- package/dist/module.d.ts +3 -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 +34 -3
- package/dist/runtime/nitro/middleware/og.png.mjs +1 -1
- package/dist/runtime/nitro/routes/html.mjs +8 -2
- package/dist/runtime/nitro/utils.mjs +1 -1
- package/dist/runtime/types.d.ts +3 -0
- package/package.json +5 -4
- package/dist/client/_nuxt/IconCSS.6eedc0b4.js +0 -1
- package/dist/client/_nuxt/IconCSS.8633f909.css +0 -1
- package/dist/client/_nuxt/builds/meta/15300c75-cff7-4383-aee7-45e80c06223e.json +0 -1
|
@@ -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,33 @@ 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
|
+
// after async scripts when capo.js is enabled
|
|
63
|
+
tagPriority: 35
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
41
67
|
const { defaults } = useRuntimeConfig()["nuxt-og-image"];
|
|
42
68
|
const options = normaliseOgImageOptions(_options);
|
|
43
69
|
const optionsWithDefault = defu(options, defaults);
|
|
@@ -73,9 +99,14 @@ export async function defineOgImage(_options = {}) {
|
|
|
73
99
|
payload[key.replace(/-([a-z])/g, (g) => g[1].toUpperCase())] = val;
|
|
74
100
|
});
|
|
75
101
|
return payload;
|
|
76
|
-
}
|
|
102
|
+
},
|
|
103
|
+
// we want this to be last in our head
|
|
104
|
+
tagPosition: "bodyClose"
|
|
77
105
|
}
|
|
78
106
|
]
|
|
107
|
+
}, {
|
|
108
|
+
// after async scripts when capo.js is enabled
|
|
109
|
+
tagPriority: 35
|
|
79
110
|
});
|
|
80
111
|
}
|
|
81
112
|
}
|
|
@@ -53,7 +53,7 @@ export default defineEventHandler(async (e) => {
|
|
|
53
53
|
}
|
|
54
54
|
if (png) {
|
|
55
55
|
if (cacheEnabled && options.cacheTtl) {
|
|
56
|
-
setHeader(e, "Cache-Control", `public, max-age=${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");
|
|
@@ -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
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -35,6 +35,9 @@ export interface OgImageOptions extends Partial<ScreenshotOptions> {
|
|
|
35
35
|
alt?: string;
|
|
36
36
|
cache?: boolean;
|
|
37
37
|
cacheKey?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The time to live of the cache in milliseconds.
|
|
40
|
+
*/
|
|
38
41
|
cacheTtl?: number;
|
|
39
42
|
/**
|
|
40
43
|
* @deprecated Use `cache` instead
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-og-image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.3",
|
|
5
5
|
"packageManager": "pnpm@8.9.2",
|
|
6
6
|
"description": "Enlightened OG Image generation for Nuxt.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@nuxt/kit": "^3.8.0",
|
|
31
31
|
"@resvg/resvg-js": "^2.6.0",
|
|
32
32
|
"@resvg/resvg-wasm": "^2.6.0",
|
|
33
|
+
"@twemoji/api": "^14.0.2",
|
|
33
34
|
"@types/fs-extra": "^11.0.3",
|
|
34
35
|
"birpc": "0.2.14",
|
|
35
36
|
"chalk": "^5.3.0",
|
|
@@ -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",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"eslint": "8.52.0",
|
|
75
76
|
"jest-image-snapshot": "^6.2.0",
|
|
76
77
|
"nuxt": "^3.8.0",
|
|
77
|
-
"nuxt-icon": "0.
|
|
78
|
+
"nuxt-icon": "0.6.1",
|
|
78
79
|
"playwright": "^1.39.0",
|
|
79
80
|
"sass": "^1.69.5",
|
|
80
81
|
"vitest": "^0.34.6"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as l,H as _,I as f,n as o,o as m,c as d,s as S,_ as g}from"./entry.30bfbdb0.js";const x=l({__name:"IconCSS",props:{name:{type:String,required:!0},size:{type:String,default:""}},setup(r){_(e=>({dcb48e74:u.value}));const n=f(),s=r,p=o(()=>{var e;return((((e=n.nuxtIcon)==null?void 0:e.aliases)||{})[s.name]||s.name).replace(/^i-/,"")}),u=o(()=>`url('https://api.iconify.design/${p.value.replace(":","/")}.svg')`),a=o(()=>{var t,c,i;if(!s.size&&typeof((t=n.nuxtIcon)==null?void 0:t.size)=="boolean"&&!((c=n.nuxtIcon)!=null&&c.size))return;const e=s.size||((i=n.nuxtIcon)==null?void 0:i.size)||"1em";return String(Number(e))===e?`${e}px`:e});return(e,t)=>(m(),d("span",{style:S({width:a.value,height:a.value})},null,4))}});const z=g(x,[["__scopeId","data-v-45afbf5e"]]);export{z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
span[data-v-45afbf5e]{background-color:currentColor;display:inline-block;-webkit-mask-image:var(--dcb48e74);mask-image:var(--dcb48e74);-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;vertical-align:middle}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"15300c75-cff7-4383-aee7-45e80c06223e","timestamp":1698388897818,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|