nuxt-og-image 2.0.0-beta.62 → 2.0.0-beta.64
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/README.md +21 -20
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/{IconCSS.c2e73ab2.js → IconCSS.0d0b82a3.js} +1 -1
- package/dist/client/_nuxt/{ImageLoader.ed4bfccb.js → ImageLoader.5e990e42.js} +1 -1
- package/dist/client/_nuxt/{entry.862302d7.css → entry.1311cc29.css} +1 -1
- package/dist/client/_nuxt/entry.26a417b5.js +143 -0
- package/dist/client/_nuxt/{error-404.a94c6c21.js → error-404.e1bcbb0e.js} +1 -1
- package/dist/client/_nuxt/{error-500.3955092a.js → error-500.2ec346d9.js} +1 -1
- package/dist/client/_nuxt/index.f302b7af.js +1 -0
- package/dist/client/_nuxt/index.ffbea0a9.css +1 -0
- package/dist/client/_nuxt/options.8a6aa984.js +1 -0
- package/dist/client/_nuxt/png.d5c2bac3.js +1 -0
- package/dist/client/_nuxt/{shiki.2980d306.js → shiki.b996482a.js} +1 -1
- package/dist/client/_nuxt/svg.5db6b479.js +1 -0
- package/dist/client/_nuxt/vnodes.a94bb63b.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/client/options/index.html +2 -2
- package/dist/client/png/index.html +2 -2
- package/dist/client/svg/index.html +2 -2
- package/dist/client/vnodes/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/composables/defineOgImage.mjs +12 -56
- package/dist/runtime/composables/util.d.ts +2 -0
- package/dist/runtime/composables/util.mjs +26 -0
- package/dist/runtime/nitro/middleware/og.png.mjs +2 -2
- package/dist/runtime/nitro/plugins/prerender.mjs +1 -1
- package/dist/runtime/nitro/routes/html.mjs +4 -4
- package/dist/runtime/nitro/utils.mjs +2 -1
- package/package.json +4 -4
- package/dist/client/_nuxt/entry.f51ac6f7.js +0 -7
- package/dist/client/_nuxt/index.17db8b1a.js +0 -1
- package/dist/client/_nuxt/index.403133d8.css +0 -1
- package/dist/client/_nuxt/options.3e6c211b.js +0 -1
- package/dist/client/_nuxt/png.23a5e57c.js +0 -1
- package/dist/client/_nuxt/svg.a8bba1f1.js +0 -1
- package/dist/client/_nuxt/vnodes.64d635d6.js +0 -1
|
@@ -2,6 +2,7 @@ import { Buffer } from "node:buffer";
|
|
|
2
2
|
import { createError, defineEventHandler, sendRedirect, setHeader } from "h3";
|
|
3
3
|
import { joinURL, parseURL, withoutTrailingSlash } from "ufo";
|
|
4
4
|
import { prefixStorage } from "unstorage";
|
|
5
|
+
import { hash } from "ohash";
|
|
5
6
|
import { fetchOptions } from "../utils.mjs";
|
|
6
7
|
import { useProvider } from "#nuxt-og-image/provider";
|
|
7
8
|
import { useNitroOrigin, useRuntimeConfig, useStorage } from "#imports";
|
|
@@ -26,8 +27,7 @@ export default defineEventHandler(async (e) => {
|
|
|
26
27
|
const useCache = runtimeCacheStorage && !process.dev && options.cacheTtl && options.cacheTtl > 0 && options.cache;
|
|
27
28
|
const baseCacheKey = runtimeCacheStorage === "default" ? "/cache/og-image" : "/og-image";
|
|
28
29
|
const cache = prefixStorage(useStorage(), `${baseCacheKey}/images`);
|
|
29
|
-
|
|
30
|
-
key = key === "/" || !key ? "index" : key;
|
|
30
|
+
const key = [options.path === "/" || !options.path ? "index" : options.path, hash(options)].join(":");
|
|
31
31
|
let png;
|
|
32
32
|
if (useCache && await cache.hasItem(key)) {
|
|
33
33
|
const { value, expiresAt } = await cache.getItem(key);
|
|
@@ -2,7 +2,7 @@ import { appendHeader } from "h3";
|
|
|
2
2
|
import { joinURL } from "ufo";
|
|
3
3
|
import { prefixStorage } from "unstorage";
|
|
4
4
|
import { extractOgImageOptions } from "../utils-pure.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { useRuntimeConfig, useStorage } from "#imports";
|
|
6
6
|
const OgImagePrenderNitroPlugin = (nitroApp) => {
|
|
7
7
|
if (!process.env.prerender)
|
|
8
8
|
return;
|
|
@@ -7,7 +7,7 @@ import twemoji from "twemoji";
|
|
|
7
7
|
import { fetchOptions } from "../utils.mjs";
|
|
8
8
|
import { useNitroOrigin, useRuntimeConfig } from "#imports";
|
|
9
9
|
export default defineEventHandler(async (e) => {
|
|
10
|
-
const { fonts,
|
|
10
|
+
const { fonts, satoriOptions } = useRuntimeConfig()["nuxt-og-image"];
|
|
11
11
|
const query = getQuery(e);
|
|
12
12
|
const path = withBase(query.path || "/", useRuntimeConfig().app.baseURL);
|
|
13
13
|
const scale = query.scale;
|
|
@@ -63,8 +63,8 @@ export default defineEventHandler(async (e) => {
|
|
|
63
63
|
transform-origin: top left;
|
|
64
64
|
max-height: 100vh;
|
|
65
65
|
position: relative;
|
|
66
|
-
width: ${
|
|
67
|
-
height: ${
|
|
66
|
+
width: ${options.width}px;
|
|
67
|
+
height: ${options.height}px;
|
|
68
68
|
overflow: hidden;
|
|
69
69
|
background-color: ${mode === "dark" ? "#1b1b1b" : "#fff"};
|
|
70
70
|
}
|
|
@@ -123,7 +123,7 @@ img.emoji {
|
|
|
123
123
|
let htmlTemplate = `<!DOCTYPE html>
|
|
124
124
|
<html ${headChunk.htmlAttrs}>
|
|
125
125
|
<head>${headChunk.headTags}</head>
|
|
126
|
-
<body ${headChunk.bodyAttrs}>${headChunk.bodyTagsOpen}<div style="position: relative; display: flex; margin: 0 auto; width:
|
|
126
|
+
<body ${headChunk.bodyAttrs}>${headChunk.bodyTagsOpen}<div style="position: relative; display: flex; margin: 0 auto; width: ${options.width}px; height: ${options.height}px; overflow: hidden;">${html}</div>${headChunk.bodyTags}</body>
|
|
127
127
|
</html>`;
|
|
128
128
|
let hasInlineStyles = false;
|
|
129
129
|
const stylesheets = htmlTemplate.match(/<link rel="stylesheet" href=".*?">/g);
|
|
@@ -40,7 +40,7 @@ export async function fetchOptions(e, path) {
|
|
|
40
40
|
const { runtimeCacheStorage } = useRuntimeConfig()["nuxt-og-image"];
|
|
41
41
|
const baseCacheKey = runtimeCacheStorage === "default" ? "/cache/og-image" : "/og-image";
|
|
42
42
|
const cache = runtimeCacheStorage || process.env.prerender ? prefixStorage(useStorage(), `${baseCacheKey}/options`) : false;
|
|
43
|
-
let key =
|
|
43
|
+
let key = path.replace("/__og_image__/og.png", "");
|
|
44
44
|
key = key === "/" || !key ? "index" : key;
|
|
45
45
|
let options;
|
|
46
46
|
if (!process.dev && cache && await cache.hasItem(key)) {
|
|
@@ -60,6 +60,7 @@ export async function fetchOptions(e, path) {
|
|
|
60
60
|
if (cache) {
|
|
61
61
|
await cache.setItem(key, {
|
|
62
62
|
value: options,
|
|
63
|
+
// cache for 1 minute or 5 seconds, avoids subsequent internal fetches
|
|
63
64
|
expiresAt: Date.now() + (options.cache ? 60 * 60 * 1e3 : 5 * 1e3)
|
|
64
65
|
});
|
|
65
66
|
}
|
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.
|
|
4
|
+
"version": "2.0.0-beta.64",
|
|
5
5
|
"packageManager": "pnpm@8.6.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"inline-css": "^4.0.2",
|
|
44
44
|
"launch-editor": "^2.6.0",
|
|
45
45
|
"nuxt-icon": "^0.4.2",
|
|
46
|
-
"nuxt-site-config": "^0.
|
|
47
|
-
"nuxt-site-config-kit": "^0.
|
|
46
|
+
"nuxt-site-config": "^0.8.1",
|
|
47
|
+
"nuxt-site-config-kit": "^0.8.1",
|
|
48
48
|
"nypm": "^0.2.2",
|
|
49
49
|
"ofetch": "^1.1.1",
|
|
50
50
|
"ohash": "^1.1.2",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@antfu/eslint-config": "^0.39.6",
|
|
67
|
-
"@nuxt/devtools-edge": "0.6.6-
|
|
67
|
+
"@nuxt/devtools-edge": "0.6.6-28139075.95f3dd8",
|
|
68
68
|
"@nuxt/module-builder": "^0.4.0",
|
|
69
69
|
"@nuxt/test-utils": "3.6.1",
|
|
70
70
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|