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 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
- <!-- Your page / app.vue / layout -->
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: 'OgImage', // Nuxt Island 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
- <!-- Your page / app.vue / layout -->
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
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "ogImage",
8
- "version": "0.4.3"
8
+ "version": "0.4.5"
9
9
  }
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: "OgImage",
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: "OgImage",
139
- filePath: resolve("./runtime/components/OgImage.vue"),
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,9 @@
1
+ import { defineComponent } from "vue";
2
+ import { defineOgImage } from "#imports";
3
+ export default defineComponent({
4
+ name: "OgImage",
5
+ setup(_, { attrs }) {
6
+ defineOgImage(attrs);
7
+ return () => null;
8
+ }
9
+ });
@@ -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,9 @@
1
+ import { defineComponent } from "vue";
2
+ import { defineOgImageScreenshot } from "#imports";
3
+ export default defineComponent({
4
+ name: "OgImageScreenshot",
5
+ setup() {
6
+ defineOgImageScreenshot();
7
+ return () => null;
8
+ }
9
+ });
@@ -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/OgImage.vue</code>.</p>
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 || "OgImage"}`, {
37
+ const result = await $fetch(withQuery(`/__nuxt_island/${payload.component || "OgImageTemplate"}`, {
38
38
  props: JSON.stringify(payload)
39
39
  }));
40
40
  const head = createHeadCore();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "0.4.3",
4
+ "version": "0.4.5",
5
5
  "packageManager": "pnpm@7.8.0",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",