unhead 1.3.5 → 1.3.7

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
@@ -82,7 +82,7 @@ const PayloadPlugin = shared.defineHeadPlugin((head) => ({
82
82
  Object.keys(csrPayload).length && ctx.tags.push({
83
83
  tag: "script",
84
84
  innerHTML: JSON.stringify(csrPayload),
85
- props: { type: "text/javascript", id: "unhead:payload" }
85
+ props: { id: "unhead:payload" }
86
86
  });
87
87
  }
88
88
  }
@@ -189,22 +189,14 @@ const TemplateParamsPlugin = shared.defineHeadPlugin({
189
189
  params.separator = params.separator || "|";
190
190
  params.pageTitle = shared.processTemplateParams(params.pageTitle || title || "", params);
191
191
  for (const tag of tags) {
192
- if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string") {
192
+ if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string")
193
193
  tag.textContent = shared.processTemplateParams(tag.textContent, params);
194
- } else if (tag.tag === "meta" && typeof tag.props.content === "string") {
194
+ else if (tag.tag === "meta" && typeof tag.props.content === "string")
195
195
  tag.props.content = shared.processTemplateParams(tag.props.content, params);
196
- } else if (tag.tag === "link" && typeof tag.props.href === "string") {
196
+ else if (tag.tag === "link" && typeof tag.props.href === "string")
197
197
  tag.props.href = shared.processTemplateParams(tag.props.href, params);
198
- } else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && typeof tag.innerHTML === "string") {
199
- try {
200
- tag.innerHTML = JSON.stringify(JSON.parse(tag.innerHTML), (key, val) => {
201
- if (typeof val === "string")
202
- return shared.processTemplateParams(val, params);
203
- return val;
204
- });
205
- } catch {
206
- }
207
- }
198
+ else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && tag.innerHTML)
199
+ tag.innerHTML = shared.processTemplateParams(tag.innerHTML, params);
208
200
  }
209
201
  ctx.tags = tags.filter((tag) => tag.tag !== "templateParams");
210
202
  }
package/dist/index.mjs CHANGED
@@ -81,7 +81,7 @@ const PayloadPlugin = defineHeadPlugin((head) => ({
81
81
  Object.keys(csrPayload).length && ctx.tags.push({
82
82
  tag: "script",
83
83
  innerHTML: JSON.stringify(csrPayload),
84
- props: { type: "text/javascript", id: "unhead:payload" }
84
+ props: { id: "unhead:payload" }
85
85
  });
86
86
  }
87
87
  }
@@ -188,22 +188,14 @@ const TemplateParamsPlugin = defineHeadPlugin({
188
188
  params.separator = params.separator || "|";
189
189
  params.pageTitle = processTemplateParams(params.pageTitle || title || "", params);
190
190
  for (const tag of tags) {
191
- if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string") {
191
+ if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string")
192
192
  tag.textContent = processTemplateParams(tag.textContent, params);
193
- } else if (tag.tag === "meta" && typeof tag.props.content === "string") {
193
+ else if (tag.tag === "meta" && typeof tag.props.content === "string")
194
194
  tag.props.content = processTemplateParams(tag.props.content, params);
195
- } else if (tag.tag === "link" && typeof tag.props.href === "string") {
195
+ else if (tag.tag === "link" && typeof tag.props.href === "string")
196
196
  tag.props.href = processTemplateParams(tag.props.href, params);
197
- } else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && typeof tag.innerHTML === "string") {
198
- try {
199
- tag.innerHTML = JSON.stringify(JSON.parse(tag.innerHTML), (key, val) => {
200
- if (typeof val === "string")
201
- return processTemplateParams(val, params);
202
- return val;
203
- });
204
- } catch {
205
- }
206
- }
197
+ else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && tag.innerHTML)
198
+ tag.innerHTML = processTemplateParams(tag.innerHTML, params);
207
199
  }
208
200
  ctx.tags = tags.filter((tag) => tag.tag !== "templateParams");
209
201
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "1.3.5",
4
+ "version": "1.3.7",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -30,9 +30,9 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "hookable": "^5.5.3",
33
- "@unhead/dom": "1.3.5",
34
- "@unhead/schema": "1.3.5",
35
- "@unhead/shared": "1.3.5"
33
+ "@unhead/dom": "1.3.7",
34
+ "@unhead/schema": "1.3.7",
35
+ "@unhead/shared": "1.3.7"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "unbuild .",