unhead 1.6.0 → 1.6.2

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
@@ -190,14 +190,20 @@ const TemplateParamsPlugin = shared.defineHeadPlugin({
190
190
  delete params.separator;
191
191
  params.pageTitle = shared.processTemplateParams(params.pageTitle || title || "", params, sep);
192
192
  for (const tag of tags) {
193
- if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string")
193
+ if (tag.processTemplateParams === false)
194
+ continue;
195
+ if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string") {
194
196
  tag.textContent = shared.processTemplateParams(tag.textContent, params, sep);
195
- else if (tag.tag === "meta" && typeof tag.props.content === "string")
197
+ } else if (tag.tag === "meta" && typeof tag.props.content === "string") {
196
198
  tag.props.content = shared.processTemplateParams(tag.props.content, params, sep);
197
- else if (tag.tag === "link" && typeof tag.props.href === "string")
199
+ } else if (tag.tag === "link" && typeof tag.props.href === "string") {
198
200
  tag.props.href = shared.processTemplateParams(tag.props.href, params, sep);
199
- else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && tag.innerHTML && tag.props.id !== "unhead:payload")
200
- tag.innerHTML = shared.processTemplateParams(tag.innerHTML, params, sep);
201
+ } else if (tag.processTemplateParams === true) {
202
+ if (tag.innerHTML)
203
+ tag.innerHTML = shared.processTemplateParams(tag.innerHTML, params, sep);
204
+ else if (tag.textContent)
205
+ tag.textContent = shared.processTemplateParams(tag.textContent, params, sep);
206
+ }
201
207
  }
202
208
  ctx.tags = tags.filter((tag) => tag.tag !== "templateParams");
203
209
  }
@@ -267,10 +273,14 @@ function createHeadCore(options = {}) {
267
273
  TitleTemplatePlugin,
268
274
  ...options?.plugins || []
269
275
  ];
270
- const updated = () => hooks.callHook("entries:updated", head);
276
+ const updated = () => {
277
+ head.dirty = true;
278
+ hooks.callHook("entries:updated", head);
279
+ };
271
280
  let entryCount = 0;
272
281
  let entries = [];
273
282
  const head = {
283
+ dirty: false,
274
284
  resolvedOptions: options,
275
285
  hooks,
276
286
  headEntries() {
package/dist/index.mjs CHANGED
@@ -189,14 +189,20 @@ const TemplateParamsPlugin = defineHeadPlugin({
189
189
  delete params.separator;
190
190
  params.pageTitle = processTemplateParams(params.pageTitle || title || "", params, sep);
191
191
  for (const tag of tags) {
192
- if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string")
192
+ if (tag.processTemplateParams === false)
193
+ continue;
194
+ if (["titleTemplate", "title"].includes(tag.tag) && typeof tag.textContent === "string") {
193
195
  tag.textContent = processTemplateParams(tag.textContent, params, sep);
194
- else if (tag.tag === "meta" && typeof tag.props.content === "string")
196
+ } else if (tag.tag === "meta" && typeof tag.props.content === "string") {
195
197
  tag.props.content = processTemplateParams(tag.props.content, params, sep);
196
- else if (tag.tag === "link" && typeof tag.props.href === "string")
198
+ } else if (tag.tag === "link" && typeof tag.props.href === "string") {
197
199
  tag.props.href = processTemplateParams(tag.props.href, params, sep);
198
- else if (tag.tag === "script" && ["application/json", "application/ld+json"].includes(tag.props.type) && tag.innerHTML && tag.props.id !== "unhead:payload")
199
- tag.innerHTML = processTemplateParams(tag.innerHTML, params, sep);
200
+ } else if (tag.processTemplateParams === true) {
201
+ if (tag.innerHTML)
202
+ tag.innerHTML = processTemplateParams(tag.innerHTML, params, sep);
203
+ else if (tag.textContent)
204
+ tag.textContent = processTemplateParams(tag.textContent, params, sep);
205
+ }
200
206
  }
201
207
  ctx.tags = tags.filter((tag) => tag.tag !== "templateParams");
202
208
  }
@@ -266,10 +272,14 @@ function createHeadCore(options = {}) {
266
272
  TitleTemplatePlugin,
267
273
  ...options?.plugins || []
268
274
  ];
269
- const updated = () => hooks.callHook("entries:updated", head);
275
+ const updated = () => {
276
+ head.dirty = true;
277
+ hooks.callHook("entries:updated", head);
278
+ };
270
279
  let entryCount = 0;
271
280
  let entries = [];
272
281
  const head = {
282
+ dirty: false,
273
283
  resolvedOptions: options,
274
284
  hooks,
275
285
  headEntries() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "1.6.2",
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.6.0",
34
- "@unhead/schema": "1.6.0",
35
- "@unhead/shared": "1.6.0"
33
+ "@unhead/dom": "1.6.2",
34
+ "@unhead/schema": "1.6.2",
35
+ "@unhead/shared": "1.6.2"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "unbuild .",