nuxt-og-image 0.4.3 → 0.4.5
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 +16 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +10 -3
- package/dist/runtime/components/OgImage.d.ts +10 -0
- package/dist/runtime/components/OgImage.mjs +9 -0
- package/dist/runtime/components/OgImageScreenshot.d.ts +10 -0
- package/dist/runtime/components/OgImageScreenshot.mjs +9 -0
- package/dist/runtime/components/{OgImage.vue → OgImageTemplate.island.vue} +1 -1
- package/dist/runtime/nitro/html.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ Generate dynamic social share images for you Nuxt v3 app.
|
|
|
32
32
|
- 🧙 Generate images for your entire site in minutes with minimal config
|
|
33
33
|
- 🎨 Build your own template with Vue (powered by Nuxt Islands)
|
|
34
34
|
- 📸 OR just generates page screenshots
|
|
35
|
+
- 📦 Composable and component API
|
|
35
36
|
|
|
36
37
|
## Install
|
|
37
38
|
|
|
@@ -128,13 +129,17 @@ export default defineNuxtConfig({
|
|
|
128
129
|
|
|
129
130
|
## Generating Screenshots
|
|
130
131
|
|
|
132
|
+
_Your page / app.vue / layout_
|
|
133
|
+
|
|
131
134
|
```vue
|
|
132
135
|
<script lang="ts" setup>
|
|
136
|
+
// Choose either Composition API
|
|
133
137
|
defineOgImageScreenshot()
|
|
134
138
|
</script>
|
|
135
139
|
<template>
|
|
136
140
|
<div>
|
|
137
|
-
<!--
|
|
141
|
+
<!-- OR Component API -->
|
|
142
|
+
<OgImageScreenshot />
|
|
138
143
|
</div>
|
|
139
144
|
</template>
|
|
140
145
|
```
|
|
@@ -144,17 +149,21 @@ defineOgImageScreenshot()
|
|
|
144
149
|
The template image generator is powered by Nuxt Islands. This means that you can use any Vue
|
|
145
150
|
component you want to generate your images.
|
|
146
151
|
|
|
152
|
+
_Your page / app.vue / layout_
|
|
153
|
+
|
|
147
154
|
```vue
|
|
148
155
|
<script lang="ts" setup>
|
|
156
|
+
// Choose either Composition API
|
|
149
157
|
defineOgImage({
|
|
150
|
-
component: '
|
|
158
|
+
component: 'OgImageTemplate', // Nuxt Island component
|
|
151
159
|
// pass in any custom props
|
|
152
160
|
myCustomTitle: 'My Title'
|
|
153
161
|
})
|
|
154
162
|
</script>
|
|
155
163
|
<template>
|
|
156
164
|
<div>
|
|
157
|
-
<!--
|
|
165
|
+
<!-- OR Component API -->
|
|
166
|
+
<OgImage component="OgImageTemplate" my-custom-title="My Title" />
|
|
158
167
|
</div>
|
|
159
168
|
</template>
|
|
160
169
|
```
|
|
@@ -241,6 +250,10 @@ The host of your site. This is required to generate the absolute path of the og:
|
|
|
241
250
|
Allows you to generate images at runtime in production. This uses a headless browser to generate images
|
|
242
251
|
and may have deployment issues.
|
|
243
252
|
|
|
253
|
+
## Examples
|
|
254
|
+
|
|
255
|
+
- [Unhead Docs](https://github.com/unjs/unhead/tree/main/docs)
|
|
256
|
+
|
|
244
257
|
## Sponsors
|
|
245
258
|
|
|
246
259
|
<p align="center">
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -93,7 +93,7 @@ const module = defineNuxtModule({
|
|
|
93
93
|
host: nuxt.options.runtimeConfig.public?.siteUrl,
|
|
94
94
|
width: 1200,
|
|
95
95
|
height: 630,
|
|
96
|
-
defaultIslandComponent: "
|
|
96
|
+
defaultIslandComponent: "OgImageTemplate",
|
|
97
97
|
outputDir: "_og-images",
|
|
98
98
|
runtimeImages: nuxt.options.dev
|
|
99
99
|
};
|
|
@@ -135,10 +135,17 @@ declare module 'nitropack' {
|
|
|
135
135
|
from: resolve("./runtime/composables/defineOgImage")
|
|
136
136
|
});
|
|
137
137
|
await addComponent({
|
|
138
|
-
name: "
|
|
139
|
-
filePath: resolve("./runtime/components/
|
|
138
|
+
name: "OgImageTemplate",
|
|
139
|
+
filePath: resolve("./runtime/components/OgImageTemplate.island.vue"),
|
|
140
140
|
island: true
|
|
141
141
|
});
|
|
142
|
+
["OgImage", "OgImageScreenshot"].forEach((name) => {
|
|
143
|
+
addComponent({
|
|
144
|
+
name,
|
|
145
|
+
filePath: resolve(`./runtime/components/${name}`),
|
|
146
|
+
island: true
|
|
147
|
+
});
|
|
148
|
+
});
|
|
142
149
|
const runtimeDir = resolve("./runtime");
|
|
143
150
|
nuxt.options.build.transpile.push(runtimeDir);
|
|
144
151
|
const constScript = Object.entries(Constants).map(([k, v]) => `export const ${k} = '${v}'`).join("\n");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
title?: string | undefined;
|
|
3
|
+
description?: string | undefined;
|
|
4
|
+
component?: string | undefined;
|
|
5
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
6
|
+
title?: string | undefined;
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
component?: string | undefined;
|
|
9
|
+
}>, {}>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
title?: string | undefined;
|
|
3
|
+
description?: string | undefined;
|
|
4
|
+
component?: string | undefined;
|
|
5
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
6
|
+
title?: string | undefined;
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
component?: string | undefined;
|
|
9
|
+
}>, {}>;
|
|
10
|
+
export default _default;
|
|
@@ -12,7 +12,7 @@ const props = defineProps({
|
|
|
12
12
|
<div class="bg2" />
|
|
13
13
|
<div>
|
|
14
14
|
<p>This is the default og:image template from <a href="https://github.com/harlan-zw/nuxt-og-image" target="_blank">nuxt-og-image</a>.</p>
|
|
15
|
-
<p>Create your own at <code>components/islands/
|
|
15
|
+
<p>Create your own at <code>components/islands/OgImageTemplate.vue</code>.</p>
|
|
16
16
|
</div>
|
|
17
17
|
<div>
|
|
18
18
|
<strong>Payload</strong>
|
|
@@ -34,7 +34,7 @@ export default defineEventHandler(async (req) => {
|
|
|
34
34
|
...inferOgPayload(html),
|
|
35
35
|
...getQuery(req)
|
|
36
36
|
};
|
|
37
|
-
const result = await $fetch(withQuery(`/__nuxt_island/${payload.component || "
|
|
37
|
+
const result = await $fetch(withQuery(`/__nuxt_island/${payload.component || "OgImageTemplate"}`, {
|
|
38
38
|
props: JSON.stringify(payload)
|
|
39
39
|
}));
|
|
40
40
|
const head = createHeadCore();
|