nuxt-og-image 2.0.0-beta.24 → 2.0.0-beta.26
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -259,7 +259,7 @@ const RuntimeCompatibility = {
|
|
|
259
259
|
};
|
|
260
260
|
|
|
261
261
|
function getNitroProviderCompatibility(nuxt) {
|
|
262
|
-
if (nuxt.options.dev || nuxt.options._prepare) {
|
|
262
|
+
if (nuxt.options.dev || nuxt.options._prepare || nuxt.options._generate) {
|
|
263
263
|
return defu({
|
|
264
264
|
wasm: "fetch",
|
|
265
265
|
browser: "universal"
|
|
@@ -322,15 +322,19 @@ const module = defineNuxtModule({
|
|
|
322
322
|
config.runtimeBrowser = false;
|
|
323
323
|
logger.warn("It looks like you're using a nitro target that does not support the browser provider, disabling `runtimeBrowser`.");
|
|
324
324
|
}
|
|
325
|
-
if (nitroCompatibility.browser === "lambda") {
|
|
325
|
+
if (config.runtimeBrowser && nitroCompatibility.browser === "lambda") {
|
|
326
326
|
logger.info("It looks like you're deploying to an environment which requires `chrome-aws-lambda`, checking for dependency...");
|
|
327
327
|
await ensureDependency(nuxt, "chrome-aws-lambda");
|
|
328
328
|
}
|
|
329
329
|
config.siteUrl = config.siteUrl || config.host;
|
|
330
330
|
if (!nuxt.options.dev && nuxt.options._generate && !config.siteUrl)
|
|
331
|
-
logger.warn("
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
logger.warn("Missing `ogImage.siteUrl` and site is being prerendered. This will result in broken og images.");
|
|
332
|
+
nuxt.options.nitro.storage = nuxt.options.nitro.storage || {};
|
|
333
|
+
if (nuxt.options._generate) {
|
|
334
|
+
nuxt.options.nitro.storage["og-image"] = {
|
|
335
|
+
driver: "memory"
|
|
336
|
+
};
|
|
337
|
+
} else if (config.runtimeCacheStorage && !nuxt.options.dev) {
|
|
334
338
|
nuxt.options.nitro.storage["og-image"] = config.runtimeCacheStorage;
|
|
335
339
|
}
|
|
336
340
|
if (!config.fonts.length)
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { appendHeader } from "h3";
|
|
2
2
|
import { joinURL } from "ufo";
|
|
3
|
+
import { prefixStorage } from "unstorage";
|
|
3
4
|
import { extractOgImageOptions } from "../utils-pure.mjs";
|
|
5
|
+
import { useStorage } from "#imports";
|
|
4
6
|
const OgImagePrenderNitroPlugin = (nitroApp) => {
|
|
5
7
|
if (!process.env.prerender)
|
|
6
8
|
return;
|
|
9
|
+
const cache = prefixStorage(useStorage(), "og-image-cache:options");
|
|
7
10
|
nitroApp.hooks.hook("render:html", async (ctx, { event }) => {
|
|
8
11
|
const url = event.node.req.url;
|
|
9
12
|
if (url.includes(".") || url.startsWith("/__nuxt_island/"))
|
|
@@ -11,6 +14,11 @@ const OgImagePrenderNitroPlugin = (nitroApp) => {
|
|
|
11
14
|
const options = extractOgImageOptions(ctx.head.join("\n"));
|
|
12
15
|
if (!options)
|
|
13
16
|
return;
|
|
17
|
+
await cache.setItem(url, {
|
|
18
|
+
value: JSON.stringify(options),
|
|
19
|
+
expiresAt: Date.now() + 60 * 60 * 1e3
|
|
20
|
+
// 60 minutes to prerender
|
|
21
|
+
});
|
|
14
22
|
if (options.static && options.provider === "satori")
|
|
15
23
|
appendHeader(event, "x-nitro-prerender", joinURL(url, "/__og_image__/og.png"));
|
|
16
24
|
});
|
|
@@ -9,7 +9,8 @@ import emojis from "./plugins/emojis.mjs";
|
|
|
9
9
|
import encoding from "./plugins/encoding.mjs";
|
|
10
10
|
import loadPngCreator from "#nuxt-og-image/png";
|
|
11
11
|
import loadSatori from "#nuxt-og-image/satori";
|
|
12
|
-
import {
|
|
12
|
+
import { useRuntimeConfig } from "#imports";
|
|
13
|
+
import { useNitroApp } from "#internal/nitro";
|
|
13
14
|
const satoriFonts = [];
|
|
14
15
|
let fontLoadPromise = null;
|
|
15
16
|
function loadFonts(fonts) {
|
|
@@ -12,8 +12,12 @@ export default defineEventHandler(async (e) => {
|
|
|
12
12
|
const scale = query.scale;
|
|
13
13
|
const mode = query.mode || "light";
|
|
14
14
|
let options;
|
|
15
|
-
if (query.options)
|
|
16
|
-
|
|
15
|
+
if (query.options) {
|
|
16
|
+
try {
|
|
17
|
+
options = JSON.parse(query.options);
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
17
21
|
if (!options)
|
|
18
22
|
options = await fetchOptions(e, path);
|
|
19
23
|
if (options.provider === "browser" && !options.component) {
|