nuxt-og-image 2.0.0-beta.25 → 2.0.0-beta.27

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
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "ogImage",
8
- "version": "2.0.0-beta.25"
8
+ "version": "2.0.0-beta.27"
9
9
  }
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
- if (config.runtimeCacheStorage && !nuxt.options.dev) {
333
- nuxt.options.nitro.storage = nuxt.options.nitro.storage || {};
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
  });
@@ -40,7 +40,7 @@ export function wasmLoader(asyncModuleLoad, fallback) {
40
40
  }
41
41
  export async function fetchOptions(e, path) {
42
42
  const { runtimeCacheStorage } = useRuntimeConfig()["nuxt-og-image"];
43
- const cache = runtimeCacheStorage ? prefixStorage(useStorage(), "og-image-cache:options") : false;
43
+ const cache = runtimeCacheStorage || process.env.prerender ? prefixStorage(useStorage(), "og-image-cache:options") : false;
44
44
  let options;
45
45
  if (cache && await cache.hasItem(path)) {
46
46
  const cachedValue = await cache.getItem(path);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.25",
4
+ "version": "2.0.0-beta.27",
5
5
  "packageManager": "pnpm@8.1.0",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",