@unhead/addons 1.0.16 → 1.0.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/index.cjs CHANGED
@@ -10,12 +10,14 @@ const InferSeoMetaPlugin = (options) => {
10
10
  hooks: {
11
11
  entries: {
12
12
  resolve({ entries }) {
13
+ let hasOgImage = false;
13
14
  for (const entry of entries) {
14
15
  const inputKey = entry.resolvedInput ? "resolvedInput" : "input";
15
16
  const input = entry[inputKey];
16
17
  const resolvedMeta = input.meta || [];
17
18
  const title = input.title;
18
19
  const ogTitle = resolvedMeta.find((meta) => meta.property === "og:title");
20
+ hasOgImage = hasOgImage || !!resolvedMeta.find((meta) => meta.property === "og:image");
19
21
  const description = resolvedMeta.find((meta) => meta.name === "description")?.content;
20
22
  const ogDescription = resolvedMeta.find((meta) => meta.property === "og:description");
21
23
  entry[inputKey].meta = input.meta || [];
@@ -40,7 +42,7 @@ const InferSeoMetaPlugin = (options) => {
40
42
  content: options?.robots || "max-snippet: -1; max-image-preview: large; max-video-preview: -1"
41
43
  });
42
44
  }
43
- if (options?.twitterCard !== false) {
45
+ if (hasOgImage && options?.twitterCard !== false) {
44
46
  metas.push({
45
47
  property: "twitter:card",
46
48
  content: options?.twitterCard || "summary_large_image"
package/dist/index.mjs CHANGED
@@ -8,12 +8,14 @@ const InferSeoMetaPlugin = (options) => {
8
8
  hooks: {
9
9
  entries: {
10
10
  resolve({ entries }) {
11
+ let hasOgImage = false;
11
12
  for (const entry of entries) {
12
13
  const inputKey = entry.resolvedInput ? "resolvedInput" : "input";
13
14
  const input = entry[inputKey];
14
15
  const resolvedMeta = input.meta || [];
15
16
  const title = input.title;
16
17
  const ogTitle = resolvedMeta.find((meta) => meta.property === "og:title");
18
+ hasOgImage = hasOgImage || !!resolvedMeta.find((meta) => meta.property === "og:image");
17
19
  const description = resolvedMeta.find((meta) => meta.name === "description")?.content;
18
20
  const ogDescription = resolvedMeta.find((meta) => meta.property === "og:description");
19
21
  entry[inputKey].meta = input.meta || [];
@@ -38,7 +40,7 @@ const InferSeoMetaPlugin = (options) => {
38
40
  content: options?.robots || "max-snippet: -1; max-image-preview: large; max-video-preview: -1"
39
41
  });
40
42
  }
41
- if (options?.twitterCard !== false) {
43
+ if (hasOgImage && options?.twitterCard !== false) {
42
44
  metas.push({
43
45
  property: "twitter:card",
44
46
  content: options?.twitterCard || "summary_large_image"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/addons",
3
3
  "type": "module",
4
- "version": "1.0.16",
4
+ "version": "1.0.17",
5
5
  "packageManager": "pnpm@7.25.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -53,8 +53,8 @@
53
53
  "@rollup/pluginutils": "^5.0.2",
54
54
  "unplugin": "^1.0.1",
55
55
  "unplugin-ast": "^0.6.0",
56
- "@unhead/schema": "1.0.16",
57
- "unhead": "1.0.16"
56
+ "@unhead/schema": "1.0.17",
57
+ "unhead": "1.0.17"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@babel/types": "^7.20.7",