nuxt-og-image 2.0.0-beta.4 → 2.0.0-beta.41
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 +245 -47
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/IconCSS.8bbd2aa2.css +1 -0
- package/dist/client/_nuxt/IconCSS.db300c72.js +1 -0
- package/dist/client/_nuxt/ImageLoader.7571516f.css +1 -0
- package/dist/client/_nuxt/ImageLoader.9ee91833.js +1 -0
- package/dist/client/_nuxt/entry.f180d9dc.js +5 -0
- package/dist/client/_nuxt/entry.f4586a2b.css +1 -0
- package/dist/client/_nuxt/{error-404.1ff52902.js → error-404.7ee6d3e0.js} +1 -1
- package/dist/client/_nuxt/{error-500.f7d30da5.js → error-500.d9b74ae7.js} +1 -1
- package/dist/client/_nuxt/error-component.0102aa4e.js +3 -0
- package/dist/client/_nuxt/index.18957a6a.js +1 -0
- package/dist/client/_nuxt/index.403133d8.css +1 -0
- package/dist/client/_nuxt/{options.56a3e5f9.js → options.a1a5b6d3.js} +1 -1
- package/dist/client/_nuxt/{png.37f3e77b.js → png.e401832b.js} +1 -1
- package/dist/client/_nuxt/{shiki.3a930bb8.js → shiki.df675964.js} +1 -1
- package/dist/client/_nuxt/{svg.186c6bd1.js → svg.a65813fd.js} +1 -1
- package/dist/client/_nuxt/{vnodes.a799f183.js → vnodes.6e14ce87.js} +1 -1
- 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.d.ts +21 -7
- package/dist/module.json +1 -1
- package/dist/module.mjs +285 -114
- package/dist/runtime/browserUtil.d.ts +1 -0
- package/dist/runtime/browserUtil.mjs +10 -5
- package/dist/runtime/components/OgImageDynamic.d.ts +1 -1
- package/dist/runtime/components/OgImageScreenshot.d.ts +1 -1
- package/dist/runtime/components/OgImageStatic.d.ts +1 -1
- package/dist/runtime/composables/defineOgImage.mjs +15 -12
- package/dist/runtime/nitro/middleware/og.png.mjs +51 -7
- package/dist/runtime/nitro/middleware/playground.mjs +4 -3
- package/dist/runtime/nitro/plugins/prerender.d.ts +3 -0
- package/dist/runtime/nitro/plugins/prerender.mjs +26 -0
- package/dist/runtime/nitro/providers/browser/lambda.d.ts +1 -1
- package/dist/runtime/nitro/providers/browser/lambda.mjs +3 -3
- package/dist/runtime/nitro/providers/browser/{node.mjs → playwright.mjs} +0 -9
- package/dist/runtime/nitro/providers/browser/universal.d.ts +1 -0
- package/dist/runtime/nitro/providers/browser/universal.mjs +33 -0
- package/dist/runtime/nitro/providers/png/resvg-node.d.ts +5 -0
- package/dist/runtime/nitro/providers/png/resvg-node.mjs +6 -0
- package/dist/runtime/nitro/providers/png/resvg-wasm.d.ts +4 -0
- package/dist/runtime/nitro/providers/png/resvg-wasm.mjs +11 -0
- package/dist/runtime/nitro/providers/png/svg2png.mjs +11 -0
- package/dist/runtime/nitro/providers/satori/{webworker.mjs → yoga-wasm.mjs} +4 -5
- package/dist/runtime/nitro/renderers/browser.d.ts +2 -2
- package/dist/runtime/nitro/renderers/browser.mjs +14 -7
- package/dist/runtime/nitro/renderers/satori/index.d.ts +2 -2
- package/dist/runtime/nitro/renderers/satori/index.mjs +22 -15
- package/dist/runtime/nitro/renderers/satori/plugins/encoding.mjs +2 -1
- package/dist/runtime/nitro/renderers/satori/plugins/imageSrc.mjs +25 -3
- package/dist/runtime/nitro/renderers/satori/utils.d.ts +2 -2
- package/dist/runtime/nitro/renderers/satori/utils.mjs +25 -12
- package/dist/runtime/nitro/routes/debug.d.ts +4 -0
- package/dist/runtime/nitro/routes/debug.mjs +9 -0
- package/dist/runtime/nitro/routes/html.mjs +52 -14
- package/dist/runtime/nitro/routes/options.mjs +20 -22
- package/dist/runtime/nitro/routes/svg.mjs +3 -1
- package/dist/runtime/nitro/routes/vnode.mjs +3 -1
- package/dist/runtime/nitro/util-hostname.d.ts +2 -0
- package/dist/runtime/nitro/util-hostname.mjs +15 -0
- package/dist/runtime/nitro/utils-pure.d.ts +3 -2
- package/dist/runtime/nitro/utils-pure.mjs +9 -8
- package/dist/runtime/nitro/utils.d.ts +6 -8
- package/dist/runtime/nitro/utils.mjs +50 -47
- package/dist/runtime/public-assets/__nuxt_og_image__/browser-provider-not-supported.png +0 -0
- package/dist/runtime/public-assets-optional/resvg/resvg.wasm +0 -0
- package/dist/types.d.ts +6 -0
- package/package.json +33 -23
- package/dist/client/_nuxt/IconCSS.a041aca0.js +0 -1
- package/dist/client/_nuxt/ImageLoader.9bf39d71.js +0 -1
- package/dist/client/_nuxt/entry.74018bda.js +0 -5
- package/dist/client/_nuxt/entry.7a8c1ab2.css +0 -1
- package/dist/client/_nuxt/error-component.cf7543e5.js +0 -3
- package/dist/client/_nuxt/index.3f356409.js +0 -1
- package/dist/runtime/nitro/providers/svg2png/universal.mjs +0 -9
- /package/dist/runtime/nitro/providers/browser/{node.d.ts → playwright.d.ts} +0 -0
- /package/dist/runtime/nitro/providers/{svg2png/universal.d.ts → png/svg2png.d.ts} +0 -0
- /package/dist/runtime/nitro/providers/satori/{node.d.ts → default.d.ts} +0 -0
- /package/dist/runtime/nitro/providers/satori/{node.mjs → default.mjs} +0 -0
- /package/dist/runtime/nitro/providers/satori/{webworker.d.ts → yoga-wasm.d.ts} +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/inter-font}/inter-latin-ext-400-normal.woff +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/inter-font}/inter-latin-ext-700-normal.woff +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/svg2png}/svg2png.wasm +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/yoga}/yoga.wasm +0 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
Enlightened OG Image generation for Nuxt 3.
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
-
<img src="https://repository-images.githubusercontent.com/578125755/
|
|
16
|
+
<img src="https://repository-images.githubusercontent.com/578125755/90f77ca8-95be-4e06-9600-332afe1ba24f">
|
|
17
17
|
|
|
18
18
|
<p align="center">
|
|
19
19
|
<table>
|
|
@@ -38,7 +38,7 @@ Enlightened OG Image generation for Nuxt 3.
|
|
|
38
38
|
- ▲ Render using [Satori](https://github.com/vercel/satori): Tailwind classes, Google fonts, emoji support and more!
|
|
39
39
|
- 🤖 Or prerender using the Browser: Supporting painless, complex templates
|
|
40
40
|
- 📸 Feeling lazy? Just generate screenshots for every page: hide elements, wait for animations, and more
|
|
41
|
-
- ⚙️ Works on the edge: Vercel Edge and Cloudflare Workers
|
|
41
|
+
- ⚙️ Works on the edge: Vercel Edge, Netlify Edge and Cloudflare Workers
|
|
42
42
|
|
|
43
43
|
## Demos
|
|
44
44
|
|
|
@@ -46,13 +46,33 @@ Enlightened OG Image generation for Nuxt 3.
|
|
|
46
46
|
- [StackBlitz - Minimal Playground Example](https://stackblitz.com/edit/nuxt-starter-pxs3wk?file=pages/index.vue)
|
|
47
47
|
- [StackBlitz - Alpine Theme](https://stackblitz.com/edit/github-hgunsf?file=package.json)
|
|
48
48
|
|
|
49
|
+
## Runtime Provider Compatibility
|
|
50
|
+
|
|
51
|
+
Both Satori and Browser will work in Node based environments. Prerendering is fully supported.
|
|
52
|
+
|
|
53
|
+
When you want to generate dynamic images at runtime there are certain Nitro runtime limitations.
|
|
54
|
+
|
|
55
|
+
| Provider | Satori | Browser |
|
|
56
|
+
|---------------------------------------------------------------------------------|----------|---------|
|
|
57
|
+
| Node | ✅ | ✅ |
|
|
58
|
+
| [Vercel](https://nuxt-og-image-playground.vercel.app/) | ✅ | ❌ |
|
|
59
|
+
| [Vercel Edge](https://nuxt-og-image-playground-gkdt.vercel.app/) | ✅ | ❌ |
|
|
60
|
+
| [Cloudflare Pages](https://nuxt-og-image-playground.pages.dev/) | ✅ | ❌ |
|
|
61
|
+
| [Netlify](https://nuxt-og-image-playground-netlify.netlify.app/) | Soon | ❌ |
|
|
62
|
+
| [Netlify Edge](https://nuxt-og-image-playground-netlify-edge.netlify.app/) | ❌ (Soon) | ❌ |
|
|
63
|
+
| [StackBlitz](https://stackblitz.com/edit/nuxt-starter-pxs3wk?file=package.json) | ✅ | ❌ |
|
|
64
|
+
|
|
65
|
+
Other providers are yet to be tested. Please create an issue if your nitro preset is not listed.
|
|
66
|
+
|
|
49
67
|
## Install
|
|
50
68
|
|
|
69
|
+
Note: The `main` branch is documentation for the beta version, it's recommended to use this version.
|
|
70
|
+
|
|
51
71
|
```bash
|
|
52
72
|
# Install module
|
|
53
|
-
npm install --save-dev nuxt-og-image
|
|
73
|
+
npm install --save-dev nuxt-og-image@beta
|
|
54
74
|
# Using yarn
|
|
55
|
-
yarn add --dev nuxt-og-image
|
|
75
|
+
yarn add --dev nuxt-og-image@beta
|
|
56
76
|
```
|
|
57
77
|
|
|
58
78
|
## Setup
|
|
@@ -71,27 +91,6 @@ export default defineNuxtConfig({
|
|
|
71
91
|
|
|
72
92
|
This feature uses Nuxt Islands, which requires Nuxt >= 3.1.
|
|
73
93
|
|
|
74
|
-
### Add your host name
|
|
75
|
-
|
|
76
|
-
The `og:image` meta tag requires the full URL, so you must provide your site host.
|
|
77
|
-
|
|
78
|
-
_nuxt.config.ts_
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
export default defineNuxtConfig({
|
|
82
|
-
// Recommended
|
|
83
|
-
runtimeConfig: {
|
|
84
|
-
public: {
|
|
85
|
-
siteUrl: process.env.NUXT_PUBLIC_SITE_URL || 'https://example.com',
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
// OR
|
|
89
|
-
ogImage: {
|
|
90
|
-
host: 'https://example.com',
|
|
91
|
-
},
|
|
92
|
-
})
|
|
93
|
-
```
|
|
94
|
-
|
|
95
94
|
# Guides
|
|
96
95
|
|
|
97
96
|
## Your first Satori `og:image`
|
|
@@ -241,6 +240,78 @@ Out of the box, this module provides support for the following:
|
|
|
241
240
|
|
|
242
241
|
If you find Satori is too limiting for your needs, you can always use the `browser` provider to capture browser screenshots instead.
|
|
243
242
|
|
|
243
|
+
## SSG Images
|
|
244
|
+
|
|
245
|
+
When using `nuxt generate`, you will need to provide some additional configuration.
|
|
246
|
+
|
|
247
|
+
- You must provide a `siteUrl` so that the meta tags can be generated correctly as absolute URLs.
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
export default defineNuxtConfig({
|
|
251
|
+
// Recommended
|
|
252
|
+
runtimeConfig: {
|
|
253
|
+
public: {
|
|
254
|
+
siteUrl: process.env.NUXT_PUBLIC_SITE_URL || 'https://example.com',
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
// OR
|
|
258
|
+
ogImage: {
|
|
259
|
+
host: 'https://example.com',
|
|
260
|
+
},
|
|
261
|
+
})
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
- You must prerender all pages that use `og:image`.
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
export default defineNuxtConfig({
|
|
268
|
+
nitro: {
|
|
269
|
+
prerender: {
|
|
270
|
+
crawlLinks: true, // recommended
|
|
271
|
+
routes: [
|
|
272
|
+
'/',
|
|
273
|
+
// list all routes that use og:image if you're not using crawlLinks
|
|
274
|
+
'/about',
|
|
275
|
+
'/blog',
|
|
276
|
+
'/blog/my-first-post',
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## SSR Images
|
|
284
|
+
|
|
285
|
+
When using `nuxt build`, you can only use the `browser` provider with the `node` Nitro preset.
|
|
286
|
+
|
|
287
|
+
If you intend to use the `browser` provider in production, make sure you include the `playwright` dependency.
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
npm i playwright
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
You can get around this by prerendering any pages that use `og:image`. Note that dynamic browser generated images are not supported at all,
|
|
294
|
+
you should use the Satori provider.
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
export default defineNuxtConfig({
|
|
299
|
+
nitro: {
|
|
300
|
+
prerender: {
|
|
301
|
+
crawlLinks: true, // recommended
|
|
302
|
+
routes: [
|
|
303
|
+
'/',
|
|
304
|
+
// list all routes that use og:image if you're not using crawlLinks
|
|
305
|
+
'/about',
|
|
306
|
+
'/blog',
|
|
307
|
+
'/blog/my-first-post',
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
|
|
244
315
|
## Taking screenshots
|
|
245
316
|
|
|
246
317
|
If you want to simply take a screenshot of your page, you can use the `OgImageScreenshot` component or `defineOgImageScreenshot` composable.
|
|
@@ -282,6 +353,135 @@ _package.json_
|
|
|
282
353
|
}
|
|
283
354
|
```
|
|
284
355
|
|
|
356
|
+
## Custom Fonts / Supporting non-english characters
|
|
357
|
+
|
|
358
|
+
When creating your OG Image, you'll probably want to use a font custom to your project.
|
|
359
|
+
|
|
360
|
+
To make this easier for you, Google Fonts are loaded by default with Inter 400 and Inter 700.
|
|
361
|
+
|
|
362
|
+
You can easily load different Google Fonts by using their name+weight. For example:
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
export default defineNuxtConfig({
|
|
366
|
+
ogImage: {
|
|
367
|
+
fonts: [
|
|
368
|
+
// will load the Noto Sans font from Google fonts
|
|
369
|
+
'Noto+Sans:400'
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
This also lets you support non-english characters by adding the appropriate font to your config.
|
|
376
|
+
|
|
377
|
+
For example, to support Hebrew characters, you can use the config:
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
export default defineNuxtConfig({
|
|
381
|
+
ogImage: {
|
|
382
|
+
fonts: [
|
|
383
|
+
// will load this font from Google fonts
|
|
384
|
+
'Noto+Sans+Hebrew:400'
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
````
|
|
389
|
+
|
|
390
|
+
If you'd like to load a font locally,
|
|
391
|
+
then you can provide the configuration as an object:
|
|
392
|
+
|
|
393
|
+
```ts
|
|
394
|
+
export default defineNuxtConfig({
|
|
395
|
+
ogImage: {
|
|
396
|
+
fonts: [
|
|
397
|
+
{
|
|
398
|
+
name: 'optieinstein',
|
|
399
|
+
weight: 800,
|
|
400
|
+
// path must point to a public font file
|
|
401
|
+
path: '/OPTIEinstein-Black.otf',
|
|
402
|
+
}
|
|
403
|
+
],
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Make sure to set the font family in your component to match the font name.
|
|
409
|
+
|
|
410
|
+
```vue
|
|
411
|
+
<template>
|
|
412
|
+
<div :style="{ fontFamily: 'optieinstein' }">
|
|
413
|
+
<!-- Your component -->
|
|
414
|
+
</div>
|
|
415
|
+
</template>
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## Runtime Caching
|
|
419
|
+
|
|
420
|
+
When images are generated at runtime, caching is enabled by default to reduce the load on your server.
|
|
421
|
+
|
|
422
|
+
By default, it will use the default storage engine for your Nitro preset.
|
|
423
|
+
You can customise the storage engine by providing a `runtimeCacheStorage` option to the `ogImage` config.
|
|
424
|
+
|
|
425
|
+
The option takes the same configuration as the Nuxt `nitro.storage` option.
|
|
426
|
+
See the [Nitro Storage Layer](https://nitro.unjs.io/guide/storage) documentation for more details.
|
|
427
|
+
|
|
428
|
+
For example:
|
|
429
|
+
|
|
430
|
+
```ts
|
|
431
|
+
export default defineNuxtConfig({
|
|
432
|
+
ogImage: {
|
|
433
|
+
// cloudflare kv binding example, set your own config
|
|
434
|
+
runtimeCacheStorage: {
|
|
435
|
+
driver: 'cloudflare-kv-binding',
|
|
436
|
+
binding: 'OG_IMAGE_CACHE'
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
````
|
|
441
|
+
|
|
442
|
+
By default, static images will be cached for 24 hours. You can change the image TTL by providing `cacheTtl` when defining the image.
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
defineOgImageStatic({
|
|
446
|
+
// ...
|
|
447
|
+
cacheTtl: 60 * 60 * 24 * 7 // 7 days
|
|
448
|
+
})
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Alternatively, you can change the default cacheTtl time in your nuxt.config.
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
```ts
|
|
455
|
+
export default defineNuxtConfig({
|
|
456
|
+
ogImage: {
|
|
457
|
+
defaults: {
|
|
458
|
+
cacheTtl: 60 * 60 * 24 * 7 // 7 days
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
})
|
|
462
|
+
````
|
|
463
|
+
|
|
464
|
+
You can also provide a configuration for the `cacheKey`. This gives you control over the cache bursting of the images.
|
|
465
|
+
|
|
466
|
+
```vue
|
|
467
|
+
<script lang="ts" setup>
|
|
468
|
+
defineOgImageStatic({
|
|
469
|
+
cacheKey: `${myData.id}:${myData.updatedAt}`,
|
|
470
|
+
})
|
|
471
|
+
</script>
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
If you prefer not to cache your images you can always disable them by providing a `false` value.
|
|
475
|
+
|
|
476
|
+
```ts
|
|
477
|
+
export default defineNuxtConfig({
|
|
478
|
+
ogImage: {
|
|
479
|
+
// no runtime cache
|
|
480
|
+
runtimeCacheStorage: false
|
|
481
|
+
}
|
|
482
|
+
})
|
|
483
|
+
````
|
|
484
|
+
|
|
285
485
|
# API
|
|
286
486
|
|
|
287
487
|
The module exposes a composition and component API to implement your `og:image` generation. You should pick
|
|
@@ -290,7 +490,7 @@ whichever one you prefer using.
|
|
|
290
490
|
## OgImageStatic / defineOgImageStatic
|
|
291
491
|
|
|
292
492
|
The `OgImageStatic` component and the `defineOgImageStatic` composable creates a static image
|
|
293
|
-
that will be
|
|
493
|
+
that will be prerendered.
|
|
294
494
|
|
|
295
495
|
The options follow the [OgImageOptions](#OgImageOptions) interface,
|
|
296
496
|
any additional options will be passed to the `component` as props.
|
|
@@ -322,7 +522,7 @@ defineOgImageStatic({
|
|
|
322
522
|
|
|
323
523
|
## OgImageDynamic / defineOgImageDynamic
|
|
324
524
|
|
|
325
|
-
The `OgImageDynamic` component and the `defineOgImageDynamic` composable creates a dynamic image. They are not
|
|
525
|
+
The `OgImageDynamic` component and the `defineOgImageDynamic` composable creates a dynamic image. They are not prerendered and will
|
|
326
526
|
be generated at runtime.
|
|
327
527
|
|
|
328
528
|
The options follow the [OgImageOptions](#OgImageOptions) interface,
|
|
@@ -396,12 +596,14 @@ The name of the component to use as the template. By default, it uses OgImageBas
|
|
|
396
596
|
- Required: `false`
|
|
397
597
|
|
|
398
598
|
The provider to use to generate the image. The default provider is `satori`.
|
|
399
|
-
When you use `browser` it will use
|
|
599
|
+
When you use `browser` it will use Playwright to generate the image.
|
|
400
600
|
|
|
401
|
-
### `
|
|
601
|
+
### `static`
|
|
402
602
|
|
|
403
603
|
- Type: `boolean`
|
|
404
|
-
- Default: `true` when
|
|
604
|
+
- Default: `true` when using `defineOgImageStatic`, `false` when dynamic
|
|
605
|
+
|
|
606
|
+
Controls the prerendering of the image. A non-static image is one that will be generated at runtime and not cached.
|
|
405
607
|
|
|
406
608
|
|
|
407
609
|
## OgImageScreenshot / defineOgImageScreenshot
|
|
@@ -495,13 +697,13 @@ defineOgImageScreenshot({
|
|
|
495
697
|
|
|
496
698
|
## Module Config
|
|
497
699
|
|
|
498
|
-
### `
|
|
700
|
+
### `siteUrl`
|
|
499
701
|
|
|
500
702
|
- Type: `string`
|
|
501
703
|
- Default: `undefined`
|
|
502
704
|
- Required: `true`
|
|
503
705
|
|
|
504
|
-
The
|
|
706
|
+
The site URL of your site. This is required when prerendering to generate the absolute path of the `og:image`.
|
|
505
707
|
|
|
506
708
|
### `defaults`
|
|
507
709
|
|
|
@@ -511,15 +713,6 @@ The host of your site. This is required to generate the absolute path of the `og
|
|
|
511
713
|
|
|
512
714
|
The default options to use when generating images.
|
|
513
715
|
|
|
514
|
-
### `forcePrerender`
|
|
515
|
-
|
|
516
|
-
- Type: `boolean`
|
|
517
|
-
- Default: `false`
|
|
518
|
-
- Required: `false`
|
|
519
|
-
|
|
520
|
-
This is enabled when you run `nuxi generate`. It forces all OG images to be pre-rendered as the server is not available to generate
|
|
521
|
-
runtime images.
|
|
522
|
-
|
|
523
716
|
### `fonts`
|
|
524
717
|
|
|
525
718
|
- Type: ``${string}:${number}`[]`
|
|
@@ -546,16 +739,21 @@ export default defineNuxtConfig({
|
|
|
546
739
|
|
|
547
740
|
Options to pass to Satori when generating images. See the [Satori docs](https://github.com/vercel/satori).
|
|
548
741
|
|
|
549
|
-
### `
|
|
742
|
+
### `runtimeSatori`
|
|
550
743
|
|
|
551
744
|
- Type: `boolean`
|
|
552
|
-
- Default: `
|
|
553
|
-
|
|
745
|
+
- Default: `true`
|
|
746
|
+
|
|
747
|
+
Whether to use Satori at runtime. This is useful to disable if you're prerendering all your images.
|
|
748
|
+
|
|
749
|
+
### `runtimeBrowser`
|
|
750
|
+
|
|
751
|
+
- Type: `boolean`
|
|
752
|
+
- Default: `process.dev`
|
|
554
753
|
|
|
555
|
-
|
|
556
|
-
|
|
754
|
+
Whether to use Playwright at runtime. You will need to enable this for production environments and ensure you are using
|
|
755
|
+
a supported nitro preset and have the required dependencies.
|
|
557
756
|
|
|
558
|
-
This is experimental and may not work in all environments.
|
|
559
757
|
|
|
560
758
|
## Examples
|
|
561
759
|
|
package/dist/client/200.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html >
|
|
3
3
|
<head><meta charset="utf-8">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="modulepreload" as="script" crossorigin href="/__nuxt_og_image__/client/_nuxt/entry.
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="modulepreload" as="script" crossorigin href="/__nuxt_og_image__/client/_nuxt/entry.f180d9dc.js"><link rel="preload" as="style" href="/__nuxt_og_image__/client/_nuxt/entry.f4586a2b.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt_og_image__/client/_nuxt/error-component.0102aa4e.js"><link rel="stylesheet" href="/__nuxt_og_image__/client/_nuxt/entry.f4586a2b.css"><script>"use strict";const w=window,de=document.documentElement,knownColorSchemes=["dark","light"],preference=window.localStorage.getItem("nuxt-color-mode")||"system";let value=preference==="system"?getColorScheme():preference;const forcedColorMode=de.getAttribute("data-color-mode-forced");forcedColorMode&&(value=forcedColorMode),addColorScheme(value),w["__NUXT_COLOR_MODE__"]={preference,value,getColorScheme,addColorScheme,removeColorScheme};function addColorScheme(e){const o=""+e+"",t="";de.classList?de.classList.add(o):de.className+=" "+o,t&&de.setAttribute("data-"+t,e)}function removeColorScheme(e){const o=""+e+"",t="";de.classList?de.classList.remove(o):de.className=de.className.replace(new RegExp(o,"g"),""),t&&de.removeAttribute("data-"+t)}function prefersColorScheme(e){return w.matchMedia("(prefers-color-scheme"+e+")")}function getColorScheme(){if(w.matchMedia&&prefersColorScheme("").media!=="not all"){for(const e of knownColorSchemes)if(prefersColorScheme(":"+e).matches)return e}return"light"}
|
|
5
5
|
</script></head>
|
|
6
|
-
<body ><div id="__nuxt"></div><script>window.__NUXT__={
|
|
6
|
+
<body ><div id="__nuxt"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"_errors":1,"serverRendered":2,"data":3,"state":4},{},false,{},{}]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt_og_image__/client",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="module" src="/__nuxt_og_image__/client/_nuxt/entry.f180d9dc.js" crossorigin></script></body>
|
|
7
7
|
</html>
|
package/dist/client/404.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html >
|
|
3
3
|
<head><meta charset="utf-8">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="modulepreload" as="script" crossorigin href="/__nuxt_og_image__/client/_nuxt/entry.
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="modulepreload" as="script" crossorigin href="/__nuxt_og_image__/client/_nuxt/entry.f180d9dc.js"><link rel="preload" as="style" href="/__nuxt_og_image__/client/_nuxt/entry.f4586a2b.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt_og_image__/client/_nuxt/error-component.0102aa4e.js"><link rel="stylesheet" href="/__nuxt_og_image__/client/_nuxt/entry.f4586a2b.css"><script>"use strict";const w=window,de=document.documentElement,knownColorSchemes=["dark","light"],preference=window.localStorage.getItem("nuxt-color-mode")||"system";let value=preference==="system"?getColorScheme():preference;const forcedColorMode=de.getAttribute("data-color-mode-forced");forcedColorMode&&(value=forcedColorMode),addColorScheme(value),w["__NUXT_COLOR_MODE__"]={preference,value,getColorScheme,addColorScheme,removeColorScheme};function addColorScheme(e){const o=""+e+"",t="";de.classList?de.classList.add(o):de.className+=" "+o,t&&de.setAttribute("data-"+t,e)}function removeColorScheme(e){const o=""+e+"",t="";de.classList?de.classList.remove(o):de.className=de.className.replace(new RegExp(o,"g"),""),t&&de.removeAttribute("data-"+t)}function prefersColorScheme(e){return w.matchMedia("(prefers-color-scheme"+e+")")}function getColorScheme(){if(w.matchMedia&&prefersColorScheme("").media!=="not all"){for(const e of knownColorSchemes)if(prefersColorScheme(":"+e).matches)return e}return"light"}
|
|
5
5
|
</script></head>
|
|
6
|
-
<body ><div id="__nuxt"></div><script>window.__NUXT__={
|
|
6
|
+
<body ><div id="__nuxt"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"_errors":1,"serverRendered":2,"data":3,"state":4},{},false,{},{}]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt_og_image__/client",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="module" src="/__nuxt_og_image__/client/_nuxt/entry.f180d9dc.js" crossorigin></script></body>
|
|
7
7
|
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
span[data-v-46d643c4]{background-color:currentColor;display:inline-block;-webkit-mask-image:var(--243647bc);mask-image:var(--243647bc);-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;vertical-align:middle}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r,b as u,e as p,f as t,o as l,h as _,i as d,j as m}from"./entry.f180d9dc.js";const f=r({__name:"IconCSS",props:{name:{type:String,required:!0},size:{type:String,default:""}},setup(a){const s=a;u(e=>({"243647bc":i.value}));const n=p();n?.nuxtIcon?.aliases;const c=t(()=>(n?.nuxtIcon?.aliases||{})[s.name]||s.name),i=t(()=>`url('https://api.iconify.design/${c.value.replace(":","/")}.svg')`),o=t(()=>{if(!s.size&&typeof n.nuxtIcon?.size=="boolean"&&!n.nuxtIcon?.size)return;const e=s.size||n.nuxtIcon?.size||"1em";return String(Number(e))===e?`${e}px`:e});return(e,x)=>(l(),_("span",{style:d({width:o.value,height:o.value})},null,4))}});const g=m(f,[["__scopeId","data-v-46d643c4"]]);export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
img[data-v-23ec6856]{height:auto!important;margin:0 auto;max-width:100%;transition:.4s ease-in-out;width:auto!important}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _,r as c,m,w as r,f as u,s as d,o as g,h as f,i as y,j as v}from"./entry.f180d9dc.js";const x=_({__name:"ImageLoader",props:{src:String,aspectRatio:Number,description:String},setup(a){const s=a,n=c(),o=c(0);function i(e){const t=n.value,p=Date.now();t.src="",o.value=0,t.style.opacity="0",t.onload=()=>{t.style.opacity="1",o.value=Date.now()-p},t.src=e}m(()=>{r(()=>s.src,e=>{i(e)},{immediate:!0})});const l=u(()=>s.description.replace("%s",o.value.toString()));return r(l,e=>{d.value=e}),(e,t)=>(g(),f("img",{ref_key:"image",ref:n,class:"max-h-full border-1 border-light-500 rounded",style:y({aspectRatio:a.aspectRatio})},null,4))}});const w=v(x,[["__scopeId","data-v-23ec6856"]]);export{w as _};
|