nuxt-og-image 1.0.0-beta.2 → 1.0.0-beta.3

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.0.0-beta.2"
8
+ "version": "1.0.0-beta.3"
9
9
  }
@@ -10,10 +10,10 @@ const props = defineProps({
10
10
  <div :style="{ padding: '0 60px', width: '100%', height: '100%', backgroundColor: '#0c0c0c', backgroundImage: 'linear-gradient(to bottom, #dbf4ff, #fff1f1)', display: 'flex', alignItems: 'center' }">
11
11
  <div :style="{ padding: '0 30px', display: 'flex', flexDirection: 'column' }">
12
12
  <p :style="{ fontSize: '60px', fontWeight: 'bold', marginBottom: '20px' }">
13
- {{ title }}
13
+ {{ title || 'Og Image Template' }}
14
14
  </p>
15
15
  <p :style="{ fontSize: '26px' }">
16
- {{ description }}
16
+ {{ description || 'Set a description to change me.' }}
17
17
  </p>
18
18
  </div>
19
19
  </div>
@@ -14,9 +14,13 @@ export const inferOgPayload = (html) => {
14
14
  const title = html.match(/<meta property="og:title" content="(.*?)">/)?.[1];
15
15
  if (title)
16
16
  payload.title = title;
17
+ else
18
+ payload.title = html.match(/<title>(.*?)<\/title>/)?.[1];
17
19
  const description = html.match(/<meta property="og:description" content="(.*?)">/)?.[1];
18
20
  if (description)
19
21
  payload.description = description;
22
+ else
23
+ payload.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
20
24
  return payload;
21
25
  };
22
26
  export default defineEventHandler(async (e) => {
@@ -34,20 +38,11 @@ export default defineEventHandler(async (e) => {
34
38
  e.node.req.url = e.path;
35
39
  if (routeRules === false)
36
40
  return false;
37
- let payload = {
41
+ return {
38
42
  path: basePath,
39
- ...extractOgPayload(html),
40
43
  ...inferOgPayload(html),
41
44
  ...routeRules || {},
45
+ ...extractOgPayload(html),
42
46
  ...getQuery(e)
43
47
  };
44
- if (payload.provider === "satori") {
45
- payload = {
46
- title: "Hello World",
47
- description: "Example description",
48
- image: "https://example.com/image.png",
49
- ...payload
50
- };
51
- }
52
- return payload;
53
48
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-beta.3",
5
5
  "packageManager": "pnpm@7.8.0",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",