unhead 1.1.20 → 1.1.22

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
@@ -301,12 +301,20 @@ function TemplateParamsPlugin() {
301
301
  const params = idx !== -1 ? tags[idx].textContent : {};
302
302
  params.pageTitle = params.pageTitle || title || "";
303
303
  for (const tag of tags) {
304
- if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string")
304
+ if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string") {
305
305
  tag.textContent = processTemplateParams(tag.textContent, params);
306
- else if (tag.tag === "meta" && typeof tag.props.content === "string")
306
+ } else if (tag.tag === "meta" && typeof tag.props.content === "string") {
307
307
  tag.props.content = processTemplateParams(tag.props.content, params);
308
- else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && typeof tag.innerHTML === "string")
309
- tag.innerHTML = processTemplateParams(tag.innerHTML, params);
308
+ } else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && typeof tag.innerHTML === "string") {
309
+ try {
310
+ tag.innerHTML = JSON.stringify(JSON.parse(tag.innerHTML), (key, val) => {
311
+ if (typeof val === "string")
312
+ return processTemplateParams(val, params);
313
+ return val;
314
+ });
315
+ } catch {
316
+ }
317
+ }
310
318
  }
311
319
  ctx.tags = tags.filter((tag) => tag.tag !== "templateParams");
312
320
  }
package/dist/index.mjs CHANGED
@@ -299,12 +299,20 @@ function TemplateParamsPlugin() {
299
299
  const params = idx !== -1 ? tags[idx].textContent : {};
300
300
  params.pageTitle = params.pageTitle || title || "";
301
301
  for (const tag of tags) {
302
- if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string")
302
+ if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string") {
303
303
  tag.textContent = processTemplateParams(tag.textContent, params);
304
- else if (tag.tag === "meta" && typeof tag.props.content === "string")
304
+ } else if (tag.tag === "meta" && typeof tag.props.content === "string") {
305
305
  tag.props.content = processTemplateParams(tag.props.content, params);
306
- else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && typeof tag.innerHTML === "string")
307
- tag.innerHTML = processTemplateParams(tag.innerHTML, params);
306
+ } else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && typeof tag.innerHTML === "string") {
307
+ try {
308
+ tag.innerHTML = JSON.stringify(JSON.parse(tag.innerHTML), (key, val) => {
309
+ if (typeof val === "string")
310
+ return processTemplateParams(val, params);
311
+ return val;
312
+ });
313
+ } catch {
314
+ }
315
+ }
308
316
  }
309
317
  ctx.tags = tags.filter((tag) => tag.tag !== "templateParams");
310
318
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "1.1.20",
4
+ "version": "1.1.22",
5
5
  "packageManager": "pnpm@7.28.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -31,9 +31,9 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "hookable": "^5.4.2",
34
- "@unhead/dom": "1.1.20",
35
- "@unhead/schema": "1.1.20",
36
- "@unhead/shared": "1.1.20"
34
+ "@unhead/dom": "1.1.22",
35
+ "@unhead/schema": "1.1.22",
36
+ "@unhead/shared": "1.1.22"
37
37
  },
38
38
  "devDependencies": {
39
39
  "packrup": "^0.1.0"