nuxt-og-image 1.0.0-beta.8 → 1.0.0
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 +335 -162
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/{Icon.bde42a7e.js → Icon.65a4f5bf.js} +1 -1
- package/dist/client/_nuxt/{entry.8f8c20b5.js → entry.9b6fba4b.js} +2 -2
- package/dist/client/_nuxt/{entry.0827acf4.css → entry.dc5450bf.css} +1 -1
- package/dist/client/_nuxt/{error-404.9ce3fbc6.js → error-404.67bc6c65.js} +1 -1
- package/dist/client/_nuxt/{error-500.d6ddcb0b.js → error-500.e3a6cf7c.js} +1 -1
- package/dist/client/_nuxt/{error-component.42929008.js → error-component.6baa49ee.js} +2 -2
- package/dist/client/index.html +2 -2
- package/dist/module.d.ts +1 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +15 -16
- package/dist/runtime/nitro/providers/satori/index.mjs +16 -6
- package/dist/runtime/nitro/providers/satori/plugins/emojis.d.ts +2 -0
- package/dist/runtime/nitro/providers/satori/plugins/emojis.mjs +13 -0
- package/dist/runtime/nitro/providers/satori/plugins/flex.mjs +1 -1
- package/dist/runtime/nitro/providers/satori/plugins/imageSrc.mjs +5 -12
- package/dist/runtime/nitro/providers/satori/utils.d.ts +4 -6
- package/dist/runtime/nitro/providers/satori/utils.mjs +56 -18
- package/dist/runtime/nitro/routes/__og_image__/font.d.ts +2 -0
- package/dist/runtime/nitro/routes/__og_image__/font.mjs +21 -0
- package/dist/runtime/nitro/routes/__og_image__/html.mjs +30 -7
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -34,17 +34,10 @@ Enlightened OG Image generation for Nuxt 3.
|
|
|
34
34
|
|
|
35
35
|
## Features
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
- Prerender static images using Satori or the browser
|
|
42
|
-
|
|
43
|
-
## Screenshots - Browser
|
|
44
|
-
|
|
45
|
-
- 📸 OR just generate screenshots
|
|
46
|
-
- ⚙️ Screenshot options to hide elements, wait for animations, and more
|
|
47
|
-
|
|
37
|
+
- 🎨 Design your `og:image` in the OG Image Playground with full HMR
|
|
38
|
+
- ▲ Blazing fast Satori provider: Tailwind classes, Google fonts, emoji support and more!
|
|
39
|
+
- 🤖 Browser provider: Supporting painless, complex templates
|
|
40
|
+
- 📸 Feeling lazy? Just generate screenshots with options for hiding elements, waiting for animations, and more
|
|
48
41
|
|
|
49
42
|
## Install
|
|
50
43
|
|
|
@@ -67,6 +60,12 @@ export default defineNuxtConfig({
|
|
|
67
60
|
})
|
|
68
61
|
```
|
|
69
62
|
|
|
63
|
+
#### Requirements
|
|
64
|
+
|
|
65
|
+
This feature uses Nuxt Islands, which requires Nuxt 3.0.1.
|
|
66
|
+
|
|
67
|
+
If you're using Nuxt 3.0.0, you will need to switch to the [edge-release channel](https://nuxt.com/docs/guide/going-further/edge-channel#edge-release-channel).
|
|
68
|
+
|
|
70
69
|
### Add your host name
|
|
71
70
|
|
|
72
71
|
The `og:image` meta tag requires the full URL, so you must provide your site host.
|
|
@@ -86,204 +85,349 @@ export default defineNuxtConfig({
|
|
|
86
85
|
})
|
|
87
86
|
```
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
# Guides
|
|
89
|
+
|
|
90
|
+
## Your first Satori `og:image`
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
For this guide, you will create your Satori OG image using the default component for your home page.
|
|
92
93
|
|
|
94
|
+
### 1. Define a static OG Image
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
Within your `pages/index.vue`, use `defineOgImageStatic` or `OgImageStatic` to define your `og:image` component.
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
Make sure you have defined some metadata for your page with `useHead` as props will be inferred from it.
|
|
97
99
|
|
|
98
100
|
```vue
|
|
99
101
|
<script lang="ts" setup>
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
+
// 1. make sure you have some meta
|
|
103
|
+
useHead({
|
|
104
|
+
title: 'Home',
|
|
105
|
+
meta: [
|
|
106
|
+
{ name: 'description', content: 'My awesome home page.' },
|
|
107
|
+
],
|
|
108
|
+
})
|
|
109
|
+
// 2a. Use the Composition API
|
|
110
|
+
defineOgImageStatic()
|
|
102
111
|
</script>
|
|
103
112
|
<template>
|
|
104
113
|
<div>
|
|
105
|
-
<!-- OR Component API -->
|
|
106
|
-
<
|
|
114
|
+
<!-- 2b. OR Component API -->
|
|
115
|
+
<OgImageStatic />
|
|
107
116
|
</div>
|
|
108
117
|
</template>
|
|
109
118
|
```
|
|
110
119
|
|
|
120
|
+
### 2. View your `og:image`
|
|
111
121
|
|
|
112
|
-
|
|
122
|
+
Appending `/__og_image__` to the end of the URL will show you the playground for that pages `og:image`. This provides
|
|
123
|
+
a live preview of your `og:image` and allows you to edit it in real-time.
|
|
113
124
|
|
|
114
|
-
|
|
125
|
+
For example, if your local site is hosted at `https://localhost:3000`, you can view your `og:image` at `https://localhost:3000/__og_image__`.
|
|
115
126
|
|
|
116
|
-
|
|
117
|
-
you should may need to install a chromium binary. You can do this by running `npx playwright install` or
|
|
118
|
-
`npm install playwright`.
|
|
127
|
+
You should see something like the following:
|
|
119
128
|
|
|
120
|
-
|
|
129
|
+
<img src="https://repository-images.githubusercontent.com/578125755/59ca1ac4-f032-4576-8179-d968a1631f1e">
|
|
121
130
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
### 3. Customize your `og:image`
|
|
132
|
+
|
|
133
|
+
While you have the playground open, start customising the OG Image by providing options to the `defineOgImageStatic` function.
|
|
134
|
+
|
|
135
|
+
```vue
|
|
136
|
+
<script lang="ts" setup>
|
|
137
|
+
defineOgImageStatic({
|
|
138
|
+
title: 'Welcome to my site!'
|
|
139
|
+
})
|
|
140
|
+
</script>
|
|
128
141
|
```
|
|
129
142
|
|
|
143
|
+
Congrats, you've set up your first Satori `og:image`!
|
|
144
|
+
|
|
145
|
+
## Making your own Satori template
|
|
130
146
|
|
|
131
|
-
|
|
147
|
+
Templates for OG images are powered by Nuxt Islands, which are just Vue components. In this guide we'll create a new
|
|
148
|
+
template and use it for our `og:image`.
|
|
132
149
|
|
|
133
|
-
|
|
134
|
-
component you want to generate your images.
|
|
150
|
+
### 1. Create an island component
|
|
135
151
|
|
|
136
|
-
|
|
152
|
+
Make a folder in your components directory called `islands`.
|
|
153
|
+
|
|
154
|
+
Within this directory make a new component called `MyOgImage.vue`,
|
|
155
|
+
you can use the following template to begin:
|
|
137
156
|
|
|
138
157
|
```vue
|
|
139
|
-
<script lang="ts"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
component: 'OgImageTemplate', // Nuxt Island component
|
|
143
|
-
alt: 'My awesome image', // alt text for image
|
|
144
|
-
// pass in any custom props
|
|
145
|
-
myCustomTitle: 'My Title'
|
|
158
|
+
<script setup lang="ts">
|
|
159
|
+
const props = defineProps({
|
|
160
|
+
title: String,
|
|
146
161
|
})
|
|
147
162
|
</script>
|
|
148
163
|
<template>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
</div>
|
|
164
|
+
<div class="w-full h-full flex text-white bg-blue-500 items-center justify-center">
|
|
165
|
+
<h1 :style="{ fontSize: '70px' }">{{ title }} 👋</h1>
|
|
166
|
+
</div>
|
|
153
167
|
</template>
|
|
154
168
|
```
|
|
155
169
|
|
|
156
|
-
###
|
|
170
|
+
### 2. Use the new template
|
|
157
171
|
|
|
158
|
-
|
|
159
|
-
to enable Nuxt Islands.
|
|
172
|
+
Now that you have your template, you can use it in for your `defineOgImageStatic` function.
|
|
160
173
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
export default defineNuxtConfig({
|
|
169
|
-
experimental: {
|
|
170
|
-
componentIslands: true
|
|
171
|
-
},
|
|
174
|
+
```vue
|
|
175
|
+
<script lang="ts" setup>
|
|
176
|
+
defineOgImageStatic({
|
|
177
|
+
component: 'MyOgImage',
|
|
178
|
+
title: 'Welcome to my site!'
|
|
172
179
|
})
|
|
180
|
+
</script>
|
|
173
181
|
```
|
|
174
182
|
|
|
175
|
-
|
|
183
|
+
View this image in your browser by appending `/__og_image__` to the end of the URL.
|
|
176
184
|
|
|
177
|
-
|
|
185
|
+
### 3. Customize your template
|
|
178
186
|
|
|
179
|
-
|
|
187
|
+
Now that you have your template, you can start customizing it.
|
|
188
|
+
|
|
189
|
+
Any options you pass to the `defineOgImageStatic` composable will be available in the component. With this in mind, we can
|
|
190
|
+
add support for changing the background color.
|
|
180
191
|
|
|
181
192
|
```vue
|
|
182
193
|
<script setup lang="ts">
|
|
183
194
|
const props = defineProps({
|
|
184
|
-
// these will always be provided
|
|
185
|
-
path: String,
|
|
186
195
|
title: String,
|
|
187
|
-
|
|
188
|
-
// anything custom comes here
|
|
189
|
-
backgroundImage: String
|
|
196
|
+
backgroundColor: String
|
|
190
197
|
})
|
|
191
198
|
</script>
|
|
192
|
-
|
|
193
199
|
<template>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
{{ title }}
|
|
198
|
-
</h1>
|
|
199
|
-
<p>{{ description }}</p>
|
|
200
|
-
</div>
|
|
201
|
-
</div>
|
|
200
|
+
<div :class="[backgroundColor]" class="w-full h-full flex text-white items-center justify-center">
|
|
201
|
+
<h1 :style="{ fontSize: '70px' }">{{ title }} 👋</h1>
|
|
202
|
+
</div>
|
|
202
203
|
</template>
|
|
204
|
+
```
|
|
203
205
|
|
|
204
|
-
|
|
205
|
-
.wrap {
|
|
206
|
-
width: 100%;
|
|
207
|
-
height: 100%;
|
|
208
|
-
display: flex;
|
|
209
|
-
align-items: center;
|
|
210
|
-
justify-content: center;
|
|
211
|
-
color: white;
|
|
212
|
-
background: linear-gradient(to bottom, #30e8bf, #ff8235);
|
|
213
|
-
}
|
|
206
|
+
Now let's customise the background to be green instead.
|
|
214
207
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
208
|
+
```vue
|
|
209
|
+
<script lang="ts" setup>
|
|
210
|
+
defineOgImageStatic({
|
|
211
|
+
component: 'MyOgImage',
|
|
212
|
+
title: 'Welcome to my site!',
|
|
213
|
+
backgroundColor: 'bg-green-500'
|
|
214
|
+
})
|
|
215
|
+
</script>
|
|
219
216
|
```
|
|
220
217
|
|
|
221
|
-
|
|
218
|
+
Within the playground, you should now see the background color change to green.
|
|
219
|
+
|
|
220
|
+
## Using Satori
|
|
221
|
+
|
|
222
|
+
It's important to familiarize yourself with [Satori](https://github.com/vercel/satori) before you make more complex templates.
|
|
223
|
+
|
|
224
|
+
Satori has limited capacity for rendering styles;
|
|
225
|
+
you should reference which ones are available within their documentation.
|
|
226
|
+
|
|
227
|
+
Out of the box, this module provides support for the following:
|
|
228
|
+
- Tailwind classes
|
|
229
|
+
- Google Fonts, default is Inter
|
|
230
|
+
- Emoji support with [Twemoji](https://github.com/twitter/twemoji)
|
|
231
|
+
- Relative image support (you should link images from your public directory `/my-image.png`)
|
|
232
|
+
|
|
233
|
+
If you find Satori is too limiting for your needs, you can always use the `browser` provider to capture browser screenshots instead.
|
|
234
|
+
|
|
235
|
+
## Taking screenshots
|
|
236
|
+
|
|
237
|
+
If you want to simply take a screenshot of your page, you can use the `OgImageScreenshot` component or `defineOgImageScreenshot` composable.
|
|
222
238
|
|
|
223
239
|
```vue
|
|
224
240
|
<script lang="ts" setup>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
defineOgImageScreenshot()
|
|
242
|
+
</script>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Alternatively you can pass the `{ provider: 'browser' }` option to `defineOgImageStatic`.
|
|
246
|
+
|
|
247
|
+
```vue
|
|
248
|
+
<script lang="ts" setup>
|
|
249
|
+
defineOgImageStatic({
|
|
250
|
+
component: 'MyAwesomeOgImage',
|
|
251
|
+
// this will take a browser screenshot
|
|
252
|
+
provider: 'browser'
|
|
228
253
|
})
|
|
229
254
|
</script>
|
|
230
255
|
```
|
|
231
256
|
|
|
232
|
-
|
|
257
|
+
### Requirements
|
|
233
258
|
|
|
234
|
-
|
|
235
|
-
the following URLs:
|
|
236
|
-
- `/your-path/__og-image` Renders the HTML output
|
|
237
|
-
- `/your-path/og-image.png` Renders the og:image
|
|
259
|
+
If you don't have a chromium binary installed on your system, run `npx playwright install`.
|
|
238
260
|
|
|
239
|
-
|
|
261
|
+
If you are using this module in a CI context and the images aren't being generated,
|
|
262
|
+
you may need to install a chromium binary.
|
|
240
263
|
|
|
241
|
-
|
|
264
|
+
You can do this by running `npx playwright install` within your build command.
|
|
242
265
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
'/',
|
|
250
|
-
// any URLs that can't be discovered by crawler
|
|
251
|
-
'/my-hidden-url'
|
|
252
|
-
]
|
|
253
|
-
}
|
|
266
|
+
_package.json_
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"scripts": {
|
|
271
|
+
"build": "npx playwright install && nuxt build"
|
|
254
272
|
}
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
# API
|
|
277
|
+
|
|
278
|
+
The module exposes a composition and component API to implement your `og:image` generation. You should pick
|
|
279
|
+
whichever one you prefer using.
|
|
280
|
+
|
|
281
|
+
## OgImageStatic / defineOgImageStatic
|
|
282
|
+
|
|
283
|
+
The `OgImageStatic` component and the `defineOgImageStatic` composable creates a static image
|
|
284
|
+
that will be pre-rendered.
|
|
285
|
+
|
|
286
|
+
The options follow the [OgImageOptions](#OgImageOptions) interface,
|
|
287
|
+
any additional options will be passed to the `component` as props.
|
|
288
|
+
|
|
289
|
+
It is useful for images that do not change at runtime.
|
|
290
|
+
|
|
291
|
+
### Example
|
|
292
|
+
|
|
293
|
+
```vue
|
|
294
|
+
<script setup lang="ts">
|
|
295
|
+
// a. Composition API
|
|
296
|
+
defineOgImageStatic({
|
|
297
|
+
component: 'MyOgImageTemplate',
|
|
298
|
+
title: 'Hello world',
|
|
299
|
+
theme: 'dark'
|
|
255
300
|
})
|
|
256
|
-
|
|
301
|
+
</script>
|
|
302
|
+
<template>
|
|
303
|
+
<!-- b. Component API -->
|
|
304
|
+
<OgImageStatic
|
|
305
|
+
component="MyOgImageTemplate"
|
|
306
|
+
title="Hello world"
|
|
307
|
+
theme="dark"
|
|
308
|
+
/>
|
|
309
|
+
</template>
|
|
310
|
+
```
|
|
257
311
|
|
|
258
|
-
## Module Config
|
|
259
312
|
|
|
260
|
-
|
|
313
|
+
## OgImageDynamic / defineOgImageDynamic
|
|
314
|
+
|
|
315
|
+
The `OgImageDynamic` component and the `defineOgImageDynamic` composable creates a dynamic image. They are not pre-rendered and will
|
|
316
|
+
be generated at runtime.
|
|
317
|
+
|
|
318
|
+
The options follow the [OgImageOptions](#OgImageOptions) interface,
|
|
319
|
+
any additional options will be passed to the `component` as props.
|
|
320
|
+
|
|
321
|
+
This feature is not compatible with static sites built using `nuxi generate`.
|
|
322
|
+
|
|
323
|
+
### Example
|
|
324
|
+
|
|
325
|
+
```vue
|
|
326
|
+
<script setup lang="ts">
|
|
327
|
+
const dynamicData = await fetch('https://example.com/api')
|
|
328
|
+
|
|
329
|
+
// a. Composition API
|
|
330
|
+
defineOgImageDynamic({
|
|
331
|
+
component: 'MyOgImageTemplate',
|
|
332
|
+
title: 'Hello world',
|
|
333
|
+
dynamicData,
|
|
334
|
+
})
|
|
335
|
+
</script>
|
|
336
|
+
<template>
|
|
337
|
+
<!-- b. Component API -->
|
|
338
|
+
<OgImageDynamic
|
|
339
|
+
component="MyOgImageTemplate"
|
|
340
|
+
title="Hello world"
|
|
341
|
+
:dynamicData="dynamicData"
|
|
342
|
+
/>
|
|
343
|
+
</template>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
## OgImageOptions
|
|
348
|
+
|
|
349
|
+
### `alt`
|
|
261
350
|
|
|
262
351
|
- Type: `string`
|
|
263
|
-
- Default: `
|
|
352
|
+
- Default: `''`
|
|
353
|
+
- Required: `false`
|
|
354
|
+
|
|
355
|
+
The `og:image:alt` attribute for the image. It should describe the contents of the image.
|
|
356
|
+
|
|
357
|
+
### `height`
|
|
358
|
+
|
|
359
|
+
- Type: `number`
|
|
360
|
+
- Default: `630`
|
|
264
361
|
- Required: `true`
|
|
265
362
|
|
|
266
|
-
The
|
|
363
|
+
The height of the screenshot. Will be used to generate the `og:image:height` meta tag.
|
|
267
364
|
|
|
268
|
-
|
|
365
|
+
### `width`
|
|
269
366
|
|
|
270
|
-
|
|
271
|
-
|
|
367
|
+
- Type: `number`
|
|
368
|
+
- Default: `1200`
|
|
369
|
+
- Required: `true`
|
|
272
370
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
371
|
+
The width of the screenshot. Will be used to generate the `og:image:width` meta tag.
|
|
372
|
+
|
|
373
|
+
### `component`
|
|
374
|
+
|
|
375
|
+
- Type: `string`
|
|
376
|
+
- Default: `OgImageBasic`
|
|
377
|
+
- Required: `true`
|
|
378
|
+
|
|
379
|
+
The name of the component to use as the template. By default, it uses OgImageBasic provided by the module.
|
|
380
|
+
|
|
381
|
+
### `provider`
|
|
382
|
+
|
|
383
|
+
- Type: `string`
|
|
384
|
+
- Default: `satori`
|
|
385
|
+
- Required: `false`
|
|
386
|
+
|
|
387
|
+
The provider to use to generate the image. The default provider is `satori`.
|
|
388
|
+
When you use `browser` it will use Puppeteer to generate the image.
|
|
389
|
+
|
|
390
|
+
### `prerender`
|
|
391
|
+
|
|
392
|
+
- Type: `boolean`
|
|
393
|
+
- Default: `true` when static, `false` when dynamic
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
## OgImageScreenshot / defineOgImageScreenshot
|
|
397
|
+
|
|
398
|
+
The `OgImageScreenshot` component and the `defineOgImageScreenshot` composable creates a screenshot of a page using a browser.
|
|
399
|
+
|
|
400
|
+
The options follow the [ScreenshotsOptions](#ScreenshotsOptions) interface.
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
### Example
|
|
404
|
+
|
|
405
|
+
```vue
|
|
406
|
+
<script setup lang="ts">
|
|
407
|
+
// a. Composition API
|
|
408
|
+
defineOgImageScreenshot({
|
|
409
|
+
// wait for animations
|
|
410
|
+
delay: 1000,
|
|
280
411
|
})
|
|
412
|
+
</script>
|
|
413
|
+
<template>
|
|
414
|
+
<!-- b. Component API -->
|
|
415
|
+
<OgImageScreenshot
|
|
416
|
+
url="https://example.com"
|
|
417
|
+
title="Hello world"
|
|
418
|
+
theme="dark"
|
|
419
|
+
/>
|
|
420
|
+
</template>
|
|
281
421
|
```
|
|
282
422
|
|
|
283
|
-
###
|
|
423
|
+
### ScreenshotsOptions
|
|
424
|
+
|
|
425
|
+
This interface extends the [OgImageOptions](#OgImageOptions).
|
|
426
|
+
|
|
427
|
+
#### `colorScheme`
|
|
284
428
|
|
|
285
429
|
- Type: `'dark' | 'light'`
|
|
286
|
-
- Default: `
|
|
430
|
+
- Default: `light`
|
|
287
431
|
- Required: `false`
|
|
288
432
|
|
|
289
433
|
The color scheme to use when generating the image. This is useful for generating dark mode images.
|
|
@@ -294,27 +438,28 @@ defineOgImageScreenshot({
|
|
|
294
438
|
})
|
|
295
439
|
```
|
|
296
440
|
|
|
297
|
-
|
|
441
|
+
#### `delay`
|
|
298
442
|
|
|
299
|
-
- Type: `
|
|
300
|
-
- Default: `
|
|
443
|
+
- Type: `number`
|
|
444
|
+
- Default: `0`
|
|
301
445
|
- Required: `false`
|
|
302
446
|
|
|
303
|
-
The
|
|
447
|
+
The delay to wait before taking the screenshot. This is useful if you want to wait for animations to complete.
|
|
304
448
|
|
|
305
449
|
```ts
|
|
306
450
|
defineOgImageScreenshot({
|
|
307
|
-
|
|
451
|
+
// wait 2 seconds
|
|
452
|
+
delay: 2000
|
|
308
453
|
})
|
|
309
454
|
```
|
|
310
455
|
|
|
311
|
-
|
|
456
|
+
#### `mask`
|
|
312
457
|
|
|
313
458
|
- Type: `string`
|
|
314
459
|
- Default: `undefined`
|
|
315
460
|
- Required: `false`
|
|
316
461
|
|
|
317
|
-
HTML selectors that should be removed from the image. Useful for removing popup banners or other elements that may be in the way.
|
|
462
|
+
HTML selectors that should be removed from the image. Useful for removing popup banners or other elements that may be in the way.
|
|
318
463
|
|
|
319
464
|
```ts
|
|
320
465
|
defineOgImageScreenshot({
|
|
@@ -322,60 +467,88 @@ defineOgImageScreenshot({
|
|
|
322
467
|
})
|
|
323
468
|
```
|
|
324
469
|
|
|
325
|
-
|
|
470
|
+
#### `selector`
|
|
326
471
|
|
|
327
|
-
- Type: `
|
|
472
|
+
- Type: `string`
|
|
328
473
|
- Default: `undefined`
|
|
329
474
|
- Required: `false`
|
|
330
475
|
|
|
331
|
-
The
|
|
476
|
+
The selector to take a screenshot of. This is useful if you want to exclude header / footer elements.
|
|
332
477
|
|
|
333
478
|
```ts
|
|
334
479
|
defineOgImageScreenshot({
|
|
335
|
-
|
|
336
|
-
delay: 2000
|
|
480
|
+
mask: '.page-content'
|
|
337
481
|
})
|
|
338
482
|
```
|
|
339
483
|
|
|
340
|
-
|
|
484
|
+
## Module Config
|
|
485
|
+
|
|
486
|
+
### `host`
|
|
341
487
|
|
|
342
488
|
- Type: `string`
|
|
343
|
-
- Default: `
|
|
489
|
+
- Default: `undefined`
|
|
490
|
+
- Required: `true`
|
|
491
|
+
|
|
492
|
+
The host of your site. This is required to generate the absolute path of the `og:image`.
|
|
493
|
+
|
|
494
|
+
### `defaults`
|
|
495
|
+
|
|
496
|
+
- Type: `OgImageOptions`
|
|
497
|
+
- Default: `{ component: 'OgImageBasic', width: 1200, height: 630, }`
|
|
344
498
|
- Required: `false`
|
|
345
499
|
|
|
346
|
-
|
|
500
|
+
The default options to use when generating images.
|
|
347
501
|
|
|
348
|
-
### `
|
|
502
|
+
### `forcePrerender`
|
|
349
503
|
|
|
350
|
-
- Type: `
|
|
351
|
-
- Default: `
|
|
352
|
-
- Required: `
|
|
504
|
+
- Type: `boolean`
|
|
505
|
+
- Default: `false`
|
|
506
|
+
- Required: `false`
|
|
353
507
|
|
|
354
|
-
|
|
508
|
+
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
|
|
509
|
+
runtime images.
|
|
355
510
|
|
|
356
|
-
|
|
357
|
-
defineOgImageScreenshot({
|
|
358
|
-
width: 1500
|
|
359
|
-
})
|
|
360
|
-
```
|
|
511
|
+
### `fonts`
|
|
361
512
|
|
|
362
|
-
|
|
513
|
+
- Type: ``${string}:${number}`[]`
|
|
514
|
+
- Default: `['Inter:400', 'Inter:700']`
|
|
515
|
+
- Required: `false`
|
|
363
516
|
|
|
364
|
-
|
|
365
|
-
- Default: `630`
|
|
366
|
-
- Required: `true`
|
|
517
|
+
Fonts families to use when generating images with Satori. When not using Inter it will automatically fetch the font from Google Fonts.
|
|
367
518
|
|
|
368
|
-
|
|
519
|
+
For example, if you wanted to add the Roboto font, you would add the following:
|
|
369
520
|
|
|
370
521
|
```ts
|
|
371
|
-
|
|
372
|
-
|
|
522
|
+
export default defineNuxtConfig({
|
|
523
|
+
ogImage: {
|
|
524
|
+
fonts: ['Roboto:400', 'Roboto:700']
|
|
525
|
+
}
|
|
373
526
|
})
|
|
374
527
|
```
|
|
375
528
|
|
|
529
|
+
### `satoriOptions`
|
|
530
|
+
|
|
531
|
+
- Type: `SatoriOptions`
|
|
532
|
+
- Default: `{}`
|
|
533
|
+
- Required: `false`
|
|
534
|
+
|
|
535
|
+
Options to pass to Satori when generating images. See the [Satori docs](https://github.com/vercel/satori).
|
|
536
|
+
|
|
537
|
+
### `experimentalNitroBrowser` (experimental)
|
|
538
|
+
|
|
539
|
+
- Type: `boolean`
|
|
540
|
+
- Default: `false`
|
|
541
|
+
- Required: `false`
|
|
542
|
+
|
|
543
|
+
In a server runtime, the default behaviour is to generate images using Satori. If you'd like to generate runtime images using the a browser instance
|
|
544
|
+
for screenshots, you can enable this setting.
|
|
545
|
+
|
|
546
|
+
This is experimental and may not work in all environments.
|
|
547
|
+
|
|
376
548
|
## Examples
|
|
377
549
|
|
|
378
550
|
- [Unhead Docs](https://github.com/unjs/unhead/tree/main/docs)
|
|
551
|
+
- [harlanzw.com](https://github.com/harlan-zw/harlanzw.com)
|
|
379
552
|
|
|
380
553
|
## Sponsors
|
|
381
554
|
|
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.9b6fba4b.js"><link rel="preload" as="style" href="/__nuxt_og_image__/client/_nuxt/entry.dc5450bf.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt_og_image__/client/_nuxt/error-component.6baa49ee.js"><link rel="stylesheet" href="/__nuxt_og_image__/client/_nuxt/entry.dc5450bf.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__={serverRendered:false,config:{public:{},app:{baseURL:"\u002F__nuxt_og_image__\u002Fclient",buildAssetsDir:"\u002F_nuxt\u002F",cdnURL:""}},data:{},state:{}}</script><script type="module" src="/__nuxt_og_image__/client/_nuxt/entry.
|
|
6
|
+
<body ><div id="__nuxt"></div><script>window.__NUXT__={serverRendered:false,config:{public:{},app:{baseURL:"\u002F__nuxt_og_image__\u002Fclient",buildAssetsDir:"\u002F_nuxt\u002F",cdnURL:""}},data:{},state:{}}</script><script type="module" src="/__nuxt_og_image__/client/_nuxt/entry.9b6fba4b.js" crossorigin></script></body>
|
|
7
7
|
</html>
|