nuxt-og-image 5.1.7 → 5.1.8
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/{DK6ySO-b.js → BM0SGHtW.js} +1 -1
- package/dist/client/_nuxt/{BuG-6Qss.js → Cl0GRg1F.js} +112 -112
- package/dist/client/_nuxt/{CN8iCxzm.js → DH3TEEXq.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/32731774-300b-4e2d-acf2-4e94bbd66b89.json +1 -0
- package/dist/client/index.html +5 -5
- package/dist/content.cjs +7 -5
- package/dist/content.d.cts +18 -2
- package/dist/content.d.mts +18 -2
- package/dist/content.d.ts +18 -2
- package/dist/content.mjs +7 -6
- package/dist/module.cjs +3 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -2
- package/dist/runtime/app/components/OgImage/OgImage.js +1 -1
- package/dist/runtime/app/components/OgImage/OgImageScreenshot.js +1 -1
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue +2 -2
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue +2 -1
- package/dist/runtime/app/components/Templates/Community/UnJs.vue +1 -1
- package/dist/runtime/app/composables/defineOgImage.js +11 -23
- package/dist/runtime/app/composables/defineOgImageScreenshot.js +2 -1
- package/dist/runtime/app/plugins/__zero-runtime/og-image-canonical-urls.server.js +1 -1
- package/dist/runtime/app/plugins/__zero-runtime/route-rule-og-image.server.js +1 -1
- package/dist/runtime/app/plugins/og-image-canonical-urls.server.js +4 -2
- package/dist/runtime/app/plugins/route-rule-og-image.server.js +4 -2
- package/dist/runtime/app/utils/plugins.d.ts +3 -3
- package/dist/runtime/app/utils/plugins.js +13 -10
- package/dist/runtime/app/utils.d.ts +3 -1
- package/dist/runtime/app/utils.js +23 -5
- package/dist/runtime/server/og-image/bindings/chromium/on-demand.js +8 -3
- package/dist/runtime/server/og-image/chromium/screenshot.js +5 -4
- package/dist/runtime/server/og-image/context.js +13 -8
- package/dist/runtime/server/og-image/satori/font.js +4 -3
- package/dist/runtime/server/og-image/satori/plugins/flex.js +1 -1
- package/dist/runtime/server/og-image/satori/plugins/imageSrc.js +11 -6
- package/dist/runtime/server/og-image/satori/renderer.js +5 -2
- package/dist/runtime/server/og-image/satori/transforms/emojis.d.ts +2 -2
- package/dist/runtime/server/og-image/satori/transforms/inlineCss.d.ts +1 -1
- package/dist/runtime/server/og-image/satori/transforms/inlineCss.js +6 -5
- package/dist/runtime/server/og-image/templates/html.js +2 -1
- package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.d.ts +1 -1
- package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.js +1 -1
- package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +1 -1
- package/dist/runtime/server/plugins/nuxt-content-v2.js +1 -1
- package/dist/runtime/server/plugins/prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/prerender.js +2 -2
- package/dist/runtime/server/routes/debug.json.js +2 -2
- package/dist/runtime/server/util/cache.js +2 -2
- package/dist/runtime/server/util/eventHandlers.js +2 -1
- package/dist/runtime/server/util/kit.d.ts +1 -1
- package/dist/runtime/server/util/kit.js +1 -1
- package/dist/runtime/server/util/plugins.js +2 -1
- package/dist/runtime/server/utils.d.ts +4 -0
- package/dist/runtime/server/utils.js +20 -0
- package/dist/runtime/shared.d.ts +13 -4
- package/dist/runtime/shared.js +103 -17
- package/dist/runtime/types.d.ts +15 -1
- package/package.json +19 -18
- package/{virtual.d.ts → types/virtual.d.ts} +11 -2
- package/dist/client/_nuxt/builds/meta/a8d773e2-13ae-466e-b246-42e9659ce587.json +0 -1
- package/dist/runtime/pure.d.ts +0 -9
- package/dist/runtime/pure.js +0 -105
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as s,u as a,c as i,o as u,a as e,t as o}from"./
|
|
1
|
+
import{_ as s,u as a,c as i,o as u,a as e,t as o}from"./Cl0GRg1F.js";const l={class:"antialiased bg-white dark:bg-black dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-black"},c={class:"max-w-520px text-center"},d=["textContent"],p=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const n=t;return a({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[{innerHTML:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{innerHTML:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1{font-size:inherit;font-weight:inherit}h1,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(g,r)=>(u(),i("div",l,[r[0]||(r[0]=e("div",{class:"-bottom-1/2 fixed h-1/2 left-0 right-0 spotlight"},null,-1)),e("div",c,[e("h1",{class:"font-medium mb-8 sm:text-10xl text-8xl",textContent:o(t.statusCode)},null,8,d),e("p",{class:"font-light leading-tight mb-16 px-8 sm:px-0 sm:text-4xl text-xl",textContent:o(t.description)},null,8,p)])]))}},h=s(f,[["__scopeId","data-v-78dd430a"]]);export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"32731774-300b-4e2d-acf2-4e94bbd66b89","timestamp":1750905317414}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"32731774-300b-4e2d-acf2-4e94bbd66b89","timestamp":1750905317414,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<!DOCTYPE html><html><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
3
|
<link rel="stylesheet" href="/__nuxt-og-image/_nuxt/entry.BVkKIlAn.css" crossorigin>
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/Cl0GRg1F.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/CVO1_9PV.js">
|
|
6
6
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/D0r3Knsf.js">
|
|
7
7
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/B8PEiB0p.js">
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/Cp-IABpG.js">
|
|
9
9
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/B6E6ObS_.js">
|
|
10
10
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-og-image/_nuxt/error-404.CWHu2lpK.css">
|
|
11
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/
|
|
11
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/BM0SGHtW.js">
|
|
12
12
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-og-image/_nuxt/error-500.xMt3qmEl.css">
|
|
13
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/
|
|
14
|
-
<script type="module" src="/__nuxt-og-image/_nuxt/
|
|
15
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-og-image",buildId:"
|
|
13
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/DH3TEEXq.js">
|
|
14
|
+
<script type="module" src="/__nuxt-og-image/_nuxt/Cl0GRg1F.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1750905323198,false]</script>
|
|
15
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-og-image",buildId:"32731774-300b-4e2d-acf2-4e94bbd66b89",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/content.cjs
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
const content = require('@nuxt/content');
|
|
4
4
|
|
|
5
|
+
const ogImageSchema = content.z.object({
|
|
6
|
+
url: content.z.string().optional(),
|
|
7
|
+
component: content.z.string().optional(),
|
|
8
|
+
props: content.z.record(content.z.string(), content.z.any())
|
|
9
|
+
}).optional();
|
|
5
10
|
const schema = content.z.object({
|
|
6
|
-
ogImage:
|
|
7
|
-
url: content.z.string().optional(),
|
|
8
|
-
component: content.z.string().optional(),
|
|
9
|
-
props: content.z.record(content.z.string(), content.z.any())
|
|
10
|
-
}).optional()
|
|
11
|
+
ogImage: ogImageSchema
|
|
11
12
|
});
|
|
12
13
|
function asOgImageCollection(collection) {
|
|
13
14
|
if (collection.type === "page") {
|
|
@@ -17,4 +18,5 @@ function asOgImageCollection(collection) {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
exports.asOgImageCollection = asOgImageCollection;
|
|
21
|
+
exports.ogImageSchema = ogImageSchema;
|
|
20
22
|
exports.schema = schema;
|
package/dist/content.d.cts
CHANGED
|
@@ -2,6 +2,19 @@ import * as zod from 'zod';
|
|
|
2
2
|
import { TypeOf, ZodRawShape } from 'zod';
|
|
3
3
|
import { Collection } from '@nuxt/content';
|
|
4
4
|
|
|
5
|
+
declare const ogImageSchema: zod.ZodOptional<zod.ZodObject<{
|
|
6
|
+
url: zod.ZodOptional<zod.ZodString>;
|
|
7
|
+
component: zod.ZodOptional<zod.ZodString>;
|
|
8
|
+
props: zod.ZodRecord<zod.ZodString, zod.ZodAny>;
|
|
9
|
+
}, "strip", zod.ZodTypeAny, {
|
|
10
|
+
props: Record<string, any>;
|
|
11
|
+
url?: string | undefined;
|
|
12
|
+
component?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
props: Record<string, any>;
|
|
15
|
+
url?: string | undefined;
|
|
16
|
+
component?: string | undefined;
|
|
17
|
+
}>>;
|
|
5
18
|
declare const schema: zod.ZodObject<{
|
|
6
19
|
ogImage: zod.ZodOptional<zod.ZodObject<{
|
|
7
20
|
url: zod.ZodOptional<zod.ZodString>;
|
|
@@ -30,7 +43,10 @@ declare const schema: zod.ZodObject<{
|
|
|
30
43
|
} | undefined;
|
|
31
44
|
}>;
|
|
32
45
|
type OgImageSchema = TypeOf<typeof schema>;
|
|
33
|
-
|
|
46
|
+
type ExtendedSchema<T extends ZodRawShape> = T & {
|
|
47
|
+
ogImage: typeof ogImageSchema;
|
|
48
|
+
};
|
|
49
|
+
declare function asOgImageCollection<T extends ZodRawShape>(collection: Collection<T>): Collection<ExtendedSchema<T>>;
|
|
34
50
|
|
|
35
|
-
export { asOgImageCollection, schema };
|
|
51
|
+
export { asOgImageCollection, ogImageSchema, schema };
|
|
36
52
|
export type { OgImageSchema };
|
package/dist/content.d.mts
CHANGED
|
@@ -2,6 +2,19 @@ import * as zod from 'zod';
|
|
|
2
2
|
import { TypeOf, ZodRawShape } from 'zod';
|
|
3
3
|
import { Collection } from '@nuxt/content';
|
|
4
4
|
|
|
5
|
+
declare const ogImageSchema: zod.ZodOptional<zod.ZodObject<{
|
|
6
|
+
url: zod.ZodOptional<zod.ZodString>;
|
|
7
|
+
component: zod.ZodOptional<zod.ZodString>;
|
|
8
|
+
props: zod.ZodRecord<zod.ZodString, zod.ZodAny>;
|
|
9
|
+
}, "strip", zod.ZodTypeAny, {
|
|
10
|
+
props: Record<string, any>;
|
|
11
|
+
url?: string | undefined;
|
|
12
|
+
component?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
props: Record<string, any>;
|
|
15
|
+
url?: string | undefined;
|
|
16
|
+
component?: string | undefined;
|
|
17
|
+
}>>;
|
|
5
18
|
declare const schema: zod.ZodObject<{
|
|
6
19
|
ogImage: zod.ZodOptional<zod.ZodObject<{
|
|
7
20
|
url: zod.ZodOptional<zod.ZodString>;
|
|
@@ -30,7 +43,10 @@ declare const schema: zod.ZodObject<{
|
|
|
30
43
|
} | undefined;
|
|
31
44
|
}>;
|
|
32
45
|
type OgImageSchema = TypeOf<typeof schema>;
|
|
33
|
-
|
|
46
|
+
type ExtendedSchema<T extends ZodRawShape> = T & {
|
|
47
|
+
ogImage: typeof ogImageSchema;
|
|
48
|
+
};
|
|
49
|
+
declare function asOgImageCollection<T extends ZodRawShape>(collection: Collection<T>): Collection<ExtendedSchema<T>>;
|
|
34
50
|
|
|
35
|
-
export { asOgImageCollection, schema };
|
|
51
|
+
export { asOgImageCollection, ogImageSchema, schema };
|
|
36
52
|
export type { OgImageSchema };
|
package/dist/content.d.ts
CHANGED
|
@@ -2,6 +2,19 @@ import * as zod from 'zod';
|
|
|
2
2
|
import { TypeOf, ZodRawShape } from 'zod';
|
|
3
3
|
import { Collection } from '@nuxt/content';
|
|
4
4
|
|
|
5
|
+
declare const ogImageSchema: zod.ZodOptional<zod.ZodObject<{
|
|
6
|
+
url: zod.ZodOptional<zod.ZodString>;
|
|
7
|
+
component: zod.ZodOptional<zod.ZodString>;
|
|
8
|
+
props: zod.ZodRecord<zod.ZodString, zod.ZodAny>;
|
|
9
|
+
}, "strip", zod.ZodTypeAny, {
|
|
10
|
+
props: Record<string, any>;
|
|
11
|
+
url?: string | undefined;
|
|
12
|
+
component?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
props: Record<string, any>;
|
|
15
|
+
url?: string | undefined;
|
|
16
|
+
component?: string | undefined;
|
|
17
|
+
}>>;
|
|
5
18
|
declare const schema: zod.ZodObject<{
|
|
6
19
|
ogImage: zod.ZodOptional<zod.ZodObject<{
|
|
7
20
|
url: zod.ZodOptional<zod.ZodString>;
|
|
@@ -30,7 +43,10 @@ declare const schema: zod.ZodObject<{
|
|
|
30
43
|
} | undefined;
|
|
31
44
|
}>;
|
|
32
45
|
type OgImageSchema = TypeOf<typeof schema>;
|
|
33
|
-
|
|
46
|
+
type ExtendedSchema<T extends ZodRawShape> = T & {
|
|
47
|
+
ogImage: typeof ogImageSchema;
|
|
48
|
+
};
|
|
49
|
+
declare function asOgImageCollection<T extends ZodRawShape>(collection: Collection<T>): Collection<ExtendedSchema<T>>;
|
|
34
50
|
|
|
35
|
-
export { asOgImageCollection, schema };
|
|
51
|
+
export { asOgImageCollection, ogImageSchema, schema };
|
|
36
52
|
export type { OgImageSchema };
|
package/dist/content.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from '@nuxt/content';
|
|
2
2
|
|
|
3
|
+
const ogImageSchema = z.object({
|
|
4
|
+
url: z.string().optional(),
|
|
5
|
+
component: z.string().optional(),
|
|
6
|
+
props: z.record(z.string(), z.any())
|
|
7
|
+
}).optional();
|
|
3
8
|
const schema = z.object({
|
|
4
|
-
ogImage:
|
|
5
|
-
url: z.string().optional(),
|
|
6
|
-
component: z.string().optional(),
|
|
7
|
-
props: z.record(z.string(), z.any())
|
|
8
|
-
}).optional()
|
|
9
|
+
ogImage: ogImageSchema
|
|
9
10
|
});
|
|
10
11
|
function asOgImageCollection(collection) {
|
|
11
12
|
if (collection.type === "page") {
|
|
@@ -14,4 +15,4 @@ function asOgImageCollection(collection) {
|
|
|
14
15
|
return collection;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export { asOgImageCollection, schema };
|
|
18
|
+
export { asOgImageCollection, ogImageSchema, schema };
|
package/dist/module.cjs
CHANGED
|
@@ -149,6 +149,7 @@ const RuntimeCompatibility = {
|
|
|
149
149
|
"satori": "node",
|
|
150
150
|
"sharp": false,
|
|
151
151
|
"wasm": {
|
|
152
|
+
// @ts-expect-error untyped
|
|
152
153
|
rollup: {
|
|
153
154
|
targetEnv: "auto-inline",
|
|
154
155
|
sync: ["@resvg/resvg-wasm/index_bg.wasm"]
|
|
@@ -309,7 +310,7 @@ async function setupBuildHandler(config, resolve, nuxt = kit.useNuxt()) {
|
|
|
309
310
|
}
|
|
310
311
|
async function resolveFilePathSha1(path) {
|
|
311
312
|
const _path = await kit.resolvePath(path);
|
|
312
|
-
return sha1(fs.existsSync(_path) ? await promises.readFile(_path) : path);
|
|
313
|
+
return sha1(fs.existsSync(_path) ? await promises.readFile(_path) : Buffer.from(path));
|
|
313
314
|
}
|
|
314
315
|
function sha1(source) {
|
|
315
316
|
return node_crypto.createHash("sha1").update(source).digest("hex").slice(0, 16);
|
|
@@ -899,7 +900,7 @@ const module$1 = kit.defineNuxtModule({
|
|
|
899
900
|
hash: ohash.hash(componentFile).replaceAll("_", "-"),
|
|
900
901
|
pascalName: component.pascalName,
|
|
901
902
|
kebabName: component.kebabName,
|
|
902
|
-
path:
|
|
903
|
+
path: component.filePath,
|
|
903
904
|
category,
|
|
904
905
|
credits
|
|
905
906
|
});
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -129,6 +129,7 @@ const RuntimeCompatibility = {
|
|
|
129
129
|
"satori": "node",
|
|
130
130
|
"sharp": false,
|
|
131
131
|
"wasm": {
|
|
132
|
+
// @ts-expect-error untyped
|
|
132
133
|
rollup: {
|
|
133
134
|
targetEnv: "auto-inline",
|
|
134
135
|
sync: ["@resvg/resvg-wasm/index_bg.wasm"]
|
|
@@ -289,7 +290,7 @@ async function setupBuildHandler(config, resolve, nuxt = useNuxt()) {
|
|
|
289
290
|
}
|
|
290
291
|
async function resolveFilePathSha1(path) {
|
|
291
292
|
const _path = await resolvePath(path);
|
|
292
|
-
return sha1(existsSync(_path) ? await readFile(_path) : path);
|
|
293
|
+
return sha1(existsSync(_path) ? await readFile(_path) : Buffer.from(path));
|
|
293
294
|
}
|
|
294
295
|
function sha1(source) {
|
|
295
296
|
return createHash("sha1").update(source).digest("hex").slice(0, 16);
|
|
@@ -879,7 +880,7 @@ const module = defineNuxtModule({
|
|
|
879
880
|
hash: hash(componentFile).replaceAll("_", "-"),
|
|
880
881
|
pascalName: component.pascalName,
|
|
881
882
|
kebabName: component.kebabName,
|
|
882
|
-
path:
|
|
883
|
+
path: component.filePath,
|
|
883
884
|
category,
|
|
884
885
|
credits
|
|
885
886
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineOgImageScreenshot } from "#imports";
|
|
2
1
|
import { defineComponent } from "vue";
|
|
2
|
+
import { defineOgImageScreenshot } from "../../composables/defineOgImageScreenshot.js";
|
|
3
3
|
export default defineComponent({
|
|
4
4
|
name: "OgImageScreenshot",
|
|
5
5
|
async setup(_, { attrs }) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useOgImageRuntimeConfig } from "#og-image/app/utils";
|
|
3
|
+
import { useSiteConfig } from "#site-config/app/composables";
|
|
4
4
|
import { computed, defineComponent, h, resolveComponent } from "vue";
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
colorMode: { type: String, required: false },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
2
|
+
import { useSiteConfig } from "#site-config/app/composables";
|
|
3
3
|
import { parseURL } from "ufo";
|
|
4
|
+
import { computed } from "vue";
|
|
4
5
|
const props = defineProps({
|
|
5
6
|
title: { type: String, required: false, default: "title" },
|
|
6
7
|
website: { type: String, required: false }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed } from "
|
|
2
|
+
import { computed } from "vue";
|
|
3
3
|
const props = defineProps({
|
|
4
4
|
title: { type: String, required: false, default: "unjs/h3" },
|
|
5
5
|
description: { type: String, required: false, default: "Minimal H(TTP) framework built for high performance and portability" },
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { appendHeader } from "h3";
|
|
2
2
|
import { createError, useNuxtApp, useRequestEvent, useRoute, useState } from "nuxt/app";
|
|
3
3
|
import { ref, toValue } from "vue";
|
|
4
|
-
import {
|
|
5
|
-
import { getOgImagePath, useOgImageRuntimeConfig } from "../../shared.js";
|
|
6
|
-
import { createOgImageMeta, setHeadOgImagePrebuilt } from "../utils.js";
|
|
4
|
+
import { createOgImageMeta, getOgImagePath, setHeadOgImagePrebuilt, useOgImageRuntimeConfig } from "../utils.js";
|
|
7
5
|
export function defineOgImage(_options = {}) {
|
|
8
6
|
const nuxtApp = useNuxtApp();
|
|
9
7
|
const route = useRoute();
|
|
@@ -21,35 +19,25 @@ export function defineOgImage(_options = {}) {
|
|
|
21
19
|
if (!import.meta.server) {
|
|
22
20
|
return;
|
|
23
21
|
}
|
|
24
|
-
const ogImageInstances = nuxtApp.ssrContext._ogImageInstances || [];
|
|
25
|
-
const routeRuleMatcher = createNitroRouteRuleMatcher();
|
|
26
|
-
const routeRules = routeRuleMatcher(basePath).ogImage;
|
|
27
|
-
if (!_options || nuxtApp.ssrContext?.event.context._nitro?.routeRules?.ogImage === false || typeof routeRules !== "undefined" && routeRules === false) {
|
|
28
|
-
ogImageInstances.forEach((e) => {
|
|
29
|
-
e.dispose();
|
|
30
|
-
});
|
|
31
|
-
nuxtApp.ssrContext._ogImageInstances = void 0;
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
22
|
const { defaults } = useOgImageRuntimeConfig();
|
|
35
23
|
const options = toValue(_options);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
options[key] = routeRules[key];
|
|
24
|
+
if (options === false) {
|
|
25
|
+
return;
|
|
39
26
|
}
|
|
27
|
+
const validOptions = options;
|
|
40
28
|
for (const key in defaults) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
29
|
+
if (validOptions[key] === void 0)
|
|
30
|
+
validOptions[key] = defaults[key];
|
|
43
31
|
}
|
|
44
32
|
if (route.query)
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
setHeadOgImagePrebuilt(
|
|
33
|
+
validOptions._query = route.query;
|
|
34
|
+
if (validOptions.url) {
|
|
35
|
+
setHeadOgImagePrebuilt(validOptions);
|
|
48
36
|
return;
|
|
49
37
|
}
|
|
50
|
-
const path = getOgImagePath(basePath,
|
|
38
|
+
const path = getOgImagePath(basePath, validOptions);
|
|
51
39
|
if (import.meta.prerender) {
|
|
52
40
|
appendHeader(useRequestEvent(nuxtApp), "x-nitro-prerender", path);
|
|
53
41
|
}
|
|
54
|
-
createOgImageMeta(path,
|
|
42
|
+
createOgImageMeta(path, validOptions, nuxtApp.ssrContext);
|
|
55
43
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRouter } from "#app";
|
|
2
|
+
import { defineOgImage } from "./defineOgImage.js";
|
|
2
3
|
export function defineOgImageScreenshot(options = {}) {
|
|
3
4
|
const router = useRouter();
|
|
4
5
|
const route = router.currentRoute.value?.path || "/";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function ogImageCanonicalUrls(nuxtApp:
|
|
3
|
-
export declare function routeRuleOgImage(nuxtApp:
|
|
1
|
+
import type { NuxtSSRContext } from '#app/nuxt';
|
|
2
|
+
export declare function ogImageCanonicalUrls(nuxtApp: NuxtSSRContext['nuxt']): void;
|
|
3
|
+
export declare function routeRuleOgImage(nuxtApp: NuxtSSRContext['nuxt']): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useRequestEvent
|
|
1
|
+
import { useRequestEvent } from "#app";
|
|
2
|
+
import { withSiteUrl } from "#site-config/app/composables";
|
|
2
3
|
import { TemplateParamsPlugin } from "@unhead/vue/plugins";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { parse, stringify } from "devalue";
|
|
@@ -6,13 +7,13 @@ import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
|
6
7
|
import { parseURL, withoutBase } from "ufo";
|
|
7
8
|
import { toValue } from "vue";
|
|
8
9
|
import { createOgImageMeta } from "../../app/utils.js";
|
|
9
|
-
import { isInternalRoute, separateProps } from "../../
|
|
10
|
-
import { getOgImagePath } from "
|
|
10
|
+
import { isInternalRoute, separateProps } from "../../shared.js";
|
|
11
|
+
import { getOgImagePath } from "../utils.js";
|
|
11
12
|
export function ogImageCanonicalUrls(nuxtApp) {
|
|
12
13
|
nuxtApp.hooks.hook("app:rendered", async (ctx) => {
|
|
13
14
|
const { ssrContext } = ctx;
|
|
14
15
|
const e = useRequestEvent();
|
|
15
|
-
const path = parseURL(e
|
|
16
|
+
const path = parseURL(e?.path || "").pathname;
|
|
16
17
|
if (isInternalRoute(path))
|
|
17
18
|
return;
|
|
18
19
|
ssrContext?.head.use(TemplateParamsPlugin);
|
|
@@ -50,7 +51,7 @@ export function ogImageCanonicalUrls(nuxtApp) {
|
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
} else if (overrides && tag.tag === "script" && tag.props.id === "nuxt-og-image-options") {
|
|
53
|
-
tag.innerHTML = stringify(defu(overrides, parse(tag.innerHTML)));
|
|
54
|
+
tag.innerHTML = stringify(defu(overrides, parse(tag.innerHTML || "{}")));
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -62,15 +63,17 @@ export function routeRuleOgImage(nuxtApp) {
|
|
|
62
63
|
nuxtApp.hooks.hook("app:rendered", async (ctx) => {
|
|
63
64
|
const { ssrContext } = ctx;
|
|
64
65
|
const e = useRequestEvent();
|
|
65
|
-
const path = parseURL(e
|
|
66
|
+
const path = parseURL(e?.path || "").pathname;
|
|
66
67
|
if (isInternalRoute(path))
|
|
67
68
|
return;
|
|
68
69
|
const _routeRulesMatcher = toRouteMatcher(
|
|
69
70
|
createRadixRouter({ routes: ssrContext?.runtimeConfig?.nitro?.routeRules })
|
|
70
71
|
);
|
|
71
|
-
|
|
72
|
-
withoutBase(path.split("?")[0], ssrContext?.runtimeConfig?.app.baseURL)
|
|
73
|
-
).reverse()
|
|
72
|
+
const matchedRules = _routeRulesMatcher.matchAll(
|
|
73
|
+
withoutBase(path.split("?")[0], ssrContext?.runtimeConfig?.app.baseURL || "")
|
|
74
|
+
).reverse();
|
|
75
|
+
const combinedRules = defu({}, ...matchedRules);
|
|
76
|
+
let routeRules = combinedRules?.ogImage;
|
|
74
77
|
if (typeof routeRules === "undefined")
|
|
75
78
|
return;
|
|
76
79
|
const ogImageInstances = nuxtApp.ssrContext._ogImageInstances || [];
|
|
@@ -82,7 +85,7 @@ export function routeRuleOgImage(nuxtApp) {
|
|
|
82
85
|
nuxtApp.ssrContext._ogImageInstances = void 0;
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
|
-
routeRules = defu(nuxtApp.ssrContext?.event
|
|
88
|
+
routeRules = defu(nuxtApp.ssrContext?.event?.context._nitro?.routeRules?.ogImage, routeRules);
|
|
86
89
|
const src = getOgImagePath(ssrContext.url, routeRules);
|
|
87
90
|
createOgImageMeta(src, routeRules, nuxtApp.ssrContext);
|
|
88
91
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { NuxtSSRContext } from 'nuxt/app';
|
|
2
|
-
import type { OgImageOptions, OgImagePrebuilt } from '../types.js';
|
|
2
|
+
import type { OgImageOptions, OgImagePrebuilt, OgImageRuntimeConfig } from '../types.js';
|
|
3
3
|
export declare function setHeadOgImagePrebuilt(input: OgImagePrebuilt): void;
|
|
4
4
|
export declare function createOgImageMeta(src: string, input: OgImageOptions | OgImagePrebuilt, ssrContext: NuxtSSRContext): void;
|
|
5
5
|
export declare function resolveComponentName(component: OgImageOptions['component'], fallback: string): OgImageOptions['component'];
|
|
6
|
+
export declare function getOgImagePath(pagePath: string, _options?: Partial<OgImageOptions>): string;
|
|
7
|
+
export declare function useOgImageRuntimeConfig(): OgImageRuntimeConfig;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { useHead, useRuntimeConfig } from "#app";
|
|
1
2
|
import { componentNames } from "#build/nuxt-og-image/components.mjs";
|
|
2
|
-
import { useHead } from "#imports";
|
|
3
3
|
import { resolveUnrefHeadInput } from "@unhead/vue";
|
|
4
4
|
import { defu } from "defu";
|
|
5
5
|
import { stringify } from "devalue";
|
|
6
|
-
import { withQuery } from "ufo";
|
|
7
|
-
import { generateMeta, separateProps
|
|
6
|
+
import { joinURL, withQuery } from "ufo";
|
|
7
|
+
import { generateMeta, separateProps } from "../shared.js";
|
|
8
8
|
export function setHeadOgImagePrebuilt(input) {
|
|
9
9
|
if (import.meta.client) {
|
|
10
10
|
return;
|
|
@@ -33,9 +33,9 @@ export function createOgImageMeta(src, input, ssrContext) {
|
|
|
33
33
|
processTemplateParams: true,
|
|
34
34
|
innerHTML: () => {
|
|
35
35
|
const payload = resolveUnrefHeadInput(_input);
|
|
36
|
-
if (typeof payload.props.title === "undefined")
|
|
36
|
+
if (payload.props && typeof payload.props.title === "undefined")
|
|
37
37
|
payload.props.title = "%s";
|
|
38
|
-
payload.component = resolveComponentName(input.component, defaults.component);
|
|
38
|
+
payload.component = resolveComponentName(input.component, defaults.component || "");
|
|
39
39
|
delete payload.url;
|
|
40
40
|
if (payload._query && Object.keys(payload._query).length === 0) {
|
|
41
41
|
delete payload._query;
|
|
@@ -73,3 +73,21 @@ export function resolveComponentName(component, fallback) {
|
|
|
73
73
|
}
|
|
74
74
|
return component;
|
|
75
75
|
}
|
|
76
|
+
export function getOgImagePath(pagePath, _options) {
|
|
77
|
+
const baseURL = useRuntimeConfig().app.baseURL;
|
|
78
|
+
const extension = _options?.extension || useOgImageRuntimeConfig().defaults.extension;
|
|
79
|
+
const path = joinURL("/", baseURL, `__og-image__/${import.meta.prerender ? "static" : "image"}`, pagePath, `og.${extension}`);
|
|
80
|
+
if (Object.keys(_options?._query || {}).length) {
|
|
81
|
+
return withQuery(path, _options._query);
|
|
82
|
+
}
|
|
83
|
+
return path;
|
|
84
|
+
}
|
|
85
|
+
export function useOgImageRuntimeConfig() {
|
|
86
|
+
const c = useRuntimeConfig();
|
|
87
|
+
return {
|
|
88
|
+
...c["nuxt-og-image"],
|
|
89
|
+
app: {
|
|
90
|
+
baseURL: c.app.baseURL
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -11,14 +11,19 @@ export async function createBrowser() {
|
|
|
11
11
|
const logger = createConsola().withTag("Nuxt OG Image");
|
|
12
12
|
logger.info("Installing Chromium install for og:image generation...");
|
|
13
13
|
const installChromeProcess = execa("npx", ["playwright", "install", "chromium"], {
|
|
14
|
-
stdio: "
|
|
14
|
+
stdio: "pipe"
|
|
15
15
|
});
|
|
16
|
-
installChromeProcess.stderr
|
|
16
|
+
if (installChromeProcess.stderr) {
|
|
17
|
+
installChromeProcess.stderr.pipe(process.stderr);
|
|
18
|
+
}
|
|
19
|
+
if (installChromeProcess.stdout) {
|
|
20
|
+
installChromeProcess.stdout.pipe(process.stdout);
|
|
21
|
+
}
|
|
17
22
|
new Promise((resolve) => {
|
|
18
23
|
installChromeProcess.on("exit", (e) => {
|
|
19
24
|
if (e !== 0)
|
|
20
25
|
logger.error("Failed to install Playwright dependency for og:image generation. Trying anyway...");
|
|
21
|
-
resolve(
|
|
26
|
+
resolve();
|
|
22
27
|
});
|
|
23
28
|
}).then(() => {
|
|
24
29
|
installChromeProcess.kill();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useNitroOrigin } from "#
|
|
1
|
+
import { useNitroOrigin } from "#site-config/server/composables";
|
|
2
2
|
import { joinURL, withQuery } from "ufo";
|
|
3
|
-
import {
|
|
3
|
+
import { toValue } from "vue";
|
|
4
|
+
import { useOgImageRuntimeConfig } from "../../utils.js";
|
|
4
5
|
export async function createScreenshot({ basePath, e, options, extension }, browser) {
|
|
5
6
|
const { colorPreference } = useOgImageRuntimeConfig();
|
|
6
7
|
const path = options.component === "PageScreenshot" ? basePath : joinURL("/__og-image__/image", basePath, `og.html`);
|
|
@@ -13,8 +14,8 @@ export async function createScreenshot({ basePath, e, options, extension }, brow
|
|
|
13
14
|
options.html = await e.$fetch(path).catch(() => void 0);
|
|
14
15
|
}
|
|
15
16
|
await page.setViewportSize({
|
|
16
|
-
width: options.width || 1200,
|
|
17
|
-
height: options.height || 630
|
|
17
|
+
width: toValue(options.width) || 1200,
|
|
18
|
+
height: toValue(options.height) || 630
|
|
18
19
|
});
|
|
19
20
|
if (options.html) {
|
|
20
21
|
const html = options.html;
|
|
@@ -11,11 +11,12 @@ import { useNitroApp } from "nitropack/runtime";
|
|
|
11
11
|
import { hash } from "ohash";
|
|
12
12
|
import { parseURL, withoutLeadingSlash, withoutTrailingSlash, withQuery } from "ufo";
|
|
13
13
|
import { normalizeKey } from "unstorage";
|
|
14
|
-
import { separateProps
|
|
14
|
+
import { separateProps } from "../../shared.js";
|
|
15
15
|
import { decodeObjectHtmlEntities } from "../util/encoding.js";
|
|
16
16
|
import { createNitroRouteRuleMatcher } from "../util/kit.js";
|
|
17
17
|
import { logger } from "../util/logger.js";
|
|
18
18
|
import { normaliseOptions } from "../util/options.js";
|
|
19
|
+
import { useOgImageRuntimeConfig } from "../utils.js";
|
|
19
20
|
import { useChromiumRenderer, useSatoriRenderer } from "./instances.js";
|
|
20
21
|
export function resolvePathCacheKey(e, path) {
|
|
21
22
|
const siteConfig = useSiteConfig(e, {
|
|
@@ -248,16 +249,17 @@ async function fetchPathHtmlAndExtractOptions(e, path, key) {
|
|
|
248
249
|
}
|
|
249
250
|
if (!_payload) {
|
|
250
251
|
const payload2 = extractAndNormaliseOgImageOptions(html);
|
|
251
|
-
if (payload2
|
|
252
|
+
if (payload2 && typeof payload2 === "object" && payload2.socialPreview?.og?.image) {
|
|
253
|
+
const image = payload2.socialPreview.og.image;
|
|
252
254
|
const p = {
|
|
253
255
|
custom: true,
|
|
254
|
-
url:
|
|
256
|
+
url: typeof image === "string" ? image : image
|
|
255
257
|
};
|
|
256
|
-
if (
|
|
257
|
-
p.width =
|
|
258
|
+
if (typeof image === "object" && image["image:width"]) {
|
|
259
|
+
p.width = image["image:width"];
|
|
258
260
|
}
|
|
259
|
-
if (
|
|
260
|
-
p.height =
|
|
261
|
+
if (typeof image === "object" && image["image:height"]) {
|
|
262
|
+
p.height = image["image:height"];
|
|
261
263
|
}
|
|
262
264
|
return p;
|
|
263
265
|
}
|
|
@@ -274,5 +276,8 @@ async function fetchPathHtmlAndExtractOptions(e, path, key) {
|
|
|
274
276
|
value: payload
|
|
275
277
|
});
|
|
276
278
|
}
|
|
277
|
-
return payload
|
|
279
|
+
return typeof payload === "object" ? payload : createError({
|
|
280
|
+
statusCode: 500,
|
|
281
|
+
statusMessage: "[Nuxt OG Image] Invalid payload type."
|
|
282
|
+
});
|
|
278
283
|
}
|