nuxt-og-image 2.0.0-beta.25 → 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
|
@@ -329,8 +329,12 @@ const module = defineNuxtModule({
|
|
|
329
329
|
config.siteUrl = config.siteUrl || config.host;
|
|
330
330
|
if (!nuxt.options.dev && nuxt.options._generate && !config.siteUrl)
|
|
331
331
|
logger.warn("Missing `ogImage.siteUrl` and site is being prerendered. This will result in broken og images.");
|
|
332
|
-
|
|
333
|
-
|
|
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
|
});
|