nuxt-og-image 1.4.15 → 1.4.17

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/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "ogImage",
8
- "version": "1.4.15"
8
+ "version": "1.4.17"
9
9
  }
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+
2
4
  const props = defineProps({
3
5
  path: String,
4
6
  title: {
@@ -1,4 +1,4 @@
1
- import { defineEventHandler, setHeader } from "h3";
1
+ import { createError, defineEventHandler, setHeader } from "h3";
2
2
  import { parseURL, withBase, withoutTrailingSlash } from "ufo";
3
3
  import { fetchOptions, useHostname } from "../utils.mjs";
4
4
  import { useProvider } from "#nuxt-og-image/provider";
@@ -16,10 +16,10 @@ export default defineEventHandler(async (e) => {
16
16
  const options = await fetchOptions(e, basePath);
17
17
  const provider = await useProvider(options.provider);
18
18
  if (!provider) {
19
- return {
20
- status: 500,
21
- body: `Provider ${options.provider} is missing.`
22
- };
19
+ throw createError({
20
+ statusCode: 500,
21
+ statusMessage: `Provider ${options.provider} is missing.`
22
+ });
23
23
  }
24
24
  return provider.createPng(withBase(basePath, useHostname(e)), options);
25
25
  });
@@ -21,14 +21,14 @@ export const inferOgImageOptions = (html) => {
21
21
  };
22
22
  export default defineEventHandler(async (e) => {
23
23
  const query = getQuery(e);
24
- const path = query.path;
24
+ const path = query.path || "/";
25
25
  const html = await globalThis.$fetch(path);
26
26
  const extractedPayload = extractOgImageOptions(html);
27
27
  if (!extractedPayload) {
28
- return {
29
- status: 500,
30
- body: `The path ${path} is missing the og-image payload.`
31
- };
28
+ throw createError({
29
+ statusCode: 500,
30
+ statusMessage: `The path ${path} is missing the og-image payload.`
31
+ });
32
32
  }
33
33
  e.node.req.url = path;
34
34
  e.context._nitro.routeRules = void 0;
@@ -1,4 +1,4 @@
1
- import { defineEventHandler, getQuery, setHeader } from "h3";
1
+ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
2
  import { withBase } from "ufo";
3
3
  import { fetchOptions, useHostname } from "../utils.mjs";
4
4
  import { useProvider } from "#nuxt-og-image/provider";
@@ -8,10 +8,10 @@ export default defineEventHandler(async (e) => {
8
8
  setHeader(e, "Content-Type", "image/svg+xml");
9
9
  const provider = await useProvider(options.provider);
10
10
  if (!provider) {
11
- return {
12
- status: 500,
13
- body: `Provider ${options.provider} is missing.`
14
- };
11
+ throw createError({
12
+ statusCode: 500,
13
+ statusMessage: `Provider ${options.provider} is missing.`
14
+ });
15
15
  }
16
16
  return provider.createSvg(withBase(path, useHostname(e)), options);
17
17
  });
@@ -1,4 +1,4 @@
1
- import { defineEventHandler, getQuery, setHeader } from "h3";
1
+ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
2
  import { withBase } from "ufo";
3
3
  import { fetchOptions, useHostname } from "../utils.mjs";
4
4
  import { useProvider } from "#nuxt-og-image/provider";
@@ -8,10 +8,10 @@ export default defineEventHandler(async (e) => {
8
8
  setHeader(e, "Content-Type", "application/json");
9
9
  const provider = await useProvider(options.provider);
10
10
  if (!provider) {
11
- return {
12
- status: 500,
13
- body: `Provider ${options.provider} is missing.`
14
- };
11
+ throw createError({
12
+ statusCode: 500,
13
+ statusMessage: `Provider ${options.provider} is missing.`
14
+ });
15
15
  }
16
16
  return provider.createVNode(withBase(path, useHostname(e)), options);
17
17
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "1.4.15",
4
+ "version": "1.4.17",
5
5
  "packageManager": "pnpm@7.8.0",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",