unhead 2.0.12 → 2.0.14

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/client.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as createUnhead } from './shared/unhead.CAk5S5m6.mjs';
1
+ import { a as createUnhead } from './shared/unhead.DH45uomy.mjs';
2
2
  import { H as HasElementTags } from './shared/unhead.yem5I2v_.mjs';
3
- import { h as hashTag, i as isMetaArrayDupeKey, a as normalizeProps, d as dedupeKey } from './shared/unhead.Di5OD67x.mjs';
3
+ import { h as hashTag, i as isMetaArrayDupeKey, a as normalizeProps, d as dedupeKey } from './shared/unhead.BpRRHAhY.mjs';
4
4
  import 'hookable';
5
5
  import './shared/unhead.DZbvapt-.mjs';
6
6
 
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.BPM0-cfG.mjs';
2
- export { c as createHeadCore, a as createUnhead } from './shared/unhead.CAk5S5m6.mjs';
2
+ export { c as createHeadCore, a as createUnhead } from './shared/unhead.DH45uomy.mjs';
3
3
  export { u as useScript } from './shared/unhead.B578PsDV.mjs';
4
4
  import './shared/unhead.CApf5sj3.mjs';
5
5
  import './shared/unhead.DQc16pHI.mjs';
6
6
  import './shared/unhead.yem5I2v_.mjs';
7
7
  import 'hookable';
8
- import './shared/unhead.Di5OD67x.mjs';
8
+ import './shared/unhead.BpRRHAhY.mjs';
9
9
  import './shared/unhead.DZbvapt-.mjs';
package/dist/legacy.mjs CHANGED
@@ -1,14 +1,14 @@
1
- import { a as createUnhead } from './shared/unhead.CAk5S5m6.mjs';
2
- import { D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.DeCxexjU.mjs';
1
+ import { a as createUnhead } from './shared/unhead.DH45uomy.mjs';
2
+ import { D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.Djo8ep_Y.mjs';
3
3
  export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.BPM0-cfG.mjs';
4
4
  export { u as useScript } from './shared/unhead.B578PsDV.mjs';
5
5
  import 'hookable';
6
- import './shared/unhead.Di5OD67x.mjs';
6
+ import './shared/unhead.BpRRHAhY.mjs';
7
7
  import './shared/unhead.yem5I2v_.mjs';
8
8
  import './shared/unhead.DZbvapt-.mjs';
9
9
  import './shared/unhead.CApf5sj3.mjs';
10
10
  import './shared/unhead.DQc16pHI.mjs';
11
- import './shared/unhead.C13swrCa.mjs';
11
+ import './shared/unhead.BYvz9V1x.mjs';
12
12
 
13
13
  const activeHead = { value: null };
14
14
  function getActiveHead() {
package/dist/plugins.mjs CHANGED
@@ -1,11 +1,21 @@
1
- export { A as AliasSortingPlugin, D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.DeCxexjU.mjs';
1
+ export { A as AliasSortingPlugin, D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.Djo8ep_Y.mjs';
2
2
  import { d as defineHeadPlugin } from './shared/unhead.CApf5sj3.mjs';
3
3
  export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.CApf5sj3.mjs';
4
4
  import './shared/unhead.DZbvapt-.mjs';
5
- import './shared/unhead.C13swrCa.mjs';
5
+ import './shared/unhead.BYvz9V1x.mjs';
6
6
  import './shared/unhead.DQc16pHI.mjs';
7
7
  import './shared/unhead.yem5I2v_.mjs';
8
8
 
9
+ const META_TRANSFORMABLE_URL = [
10
+ "og:url",
11
+ "og:image",
12
+ "og:image:secure_url",
13
+ "twitter:image",
14
+ "twitter:image:src",
15
+ "og:video",
16
+ "og:video:secure_url",
17
+ "og:see_also"
18
+ ];
9
19
  function CanonicalPlugin(options) {
10
20
  return (head) => {
11
21
  let host = options.canonicalHost || (!head.ssr ? window.location.origin : "");
@@ -30,12 +40,8 @@ function CanonicalPlugin(options) {
30
40
  hooks: {
31
41
  "tags:resolve": (ctx) => {
32
42
  for (const tag of ctx.tags) {
33
- if (tag.tag === "meta") {
34
- if (tag.props.property?.startsWith("og:image") || tag.props.name?.startsWith("twitter:image")) {
35
- tag.props.content = resolvePath(tag.props.content);
36
- } else if (tag.props?.property === "og:url") {
37
- tag.props.content = resolvePath(tag.props.content);
38
- }
43
+ if (tag.tag === "meta" && (META_TRANSFORMABLE_URL.includes(tag.props?.property) || META_TRANSFORMABLE_URL.includes(tag.props?.name))) {
44
+ tag.props.content = resolvePath(tag.props.content);
39
45
  } else if (tag.tag === "link" && tag.props.rel === "canonical") {
40
46
  tag.props.href = resolvePath(tag.props.href);
41
47
  }
package/dist/server.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { a as createUnhead } from './shared/unhead.CAk5S5m6.mjs';
1
+ import { a as createUnhead } from './shared/unhead.DH45uomy.mjs';
2
2
  import { T as TagsWithInnerContent, S as SelfClosingTags$1 } from './shared/unhead.yem5I2v_.mjs';
3
3
  import 'hookable';
4
- import './shared/unhead.Di5OD67x.mjs';
4
+ import './shared/unhead.BpRRHAhY.mjs';
5
5
  import './shared/unhead.DZbvapt-.mjs';
6
6
 
7
7
  // @__NO_SIDE_EFFECTS__
@@ -67,7 +67,7 @@ function createHead(options = {}) {
67
67
  return unhead;
68
68
  }
69
69
 
70
- const Attrs = /(\w+)(?:=["']([^"']*)["'])?/g;
70
+ const Attrs = /(\w+-?\w+)(?:=["']([^"']*)["'])?/g;
71
71
  const HtmlTag = /<html[^>]*>/;
72
72
  const BodyTag = /<body[^>]*>/;
73
73
  const HeadContent = /<head[^>]*>(.*?)<\/head>/s;
@@ -1,5 +1,4 @@
1
1
  const SepSub = "%separator";
2
- const SepSubRE = new RegExp(`${SepSub}(?:\\s*${SepSub})*`, "g");
3
2
  function sub(p, token, isJson = false) {
4
3
  let val;
5
4
  if (token === "s" || token === "pageTitle") {
@@ -36,11 +35,7 @@ function processTemplateParams(s, p, sep, isJson = false) {
36
35
  return re !== void 0 ? re : token;
37
36
  }).trim();
38
37
  if (hasSepSub) {
39
- if (s.endsWith(SepSub))
40
- s = s.slice(0, -SepSub.length);
41
- if (s.startsWith(SepSub))
42
- s = s.slice(SepSub.length);
43
- s = s.replace(SepSubRE, sep || "").trim();
38
+ s = s.split(SepSub).map((part) => part.trim()).filter((part) => part !== "").join(sep ? ` ${sep} ` : " ");
44
39
  }
45
40
  return s;
46
41
  }
@@ -112,6 +112,10 @@ function normalizeProps(tag, input) {
112
112
  if (!input) {
113
113
  return tag;
114
114
  }
115
+ if (tag.tag === "templateParams") {
116
+ tag.props = input;
117
+ return tag;
118
+ }
115
119
  Object.entries(input).forEach(([key, value]) => {
116
120
  if (value === null) {
117
121
  tag.props[key] = null;
@@ -1,5 +1,5 @@
1
1
  import { createHooks } from 'hookable';
2
- import { n as normalizeEntryToTags, d as dedupeKey, i as isMetaArrayDupeKey } from './unhead.Di5OD67x.mjs';
2
+ import { n as normalizeEntryToTags, d as dedupeKey, i as isMetaArrayDupeKey } from './unhead.BpRRHAhY.mjs';
3
3
  import { t as tagWeight, s as sortTags } from './unhead.DZbvapt-.mjs';
4
4
  import { c as UsesMergeStrategy, V as ValidHeadTags } from './unhead.yem5I2v_.mjs';
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { d as defineHeadPlugin } from './unhead.CApf5sj3.mjs';
2
2
  import { s as sortTags } from './unhead.DZbvapt-.mjs';
3
- import { p as processTemplateParams } from './unhead.C13swrCa.mjs';
3
+ import { p as processTemplateParams } from './unhead.BYvz9V1x.mjs';
4
4
 
5
5
  const formatKey = (k) => !k.includes(":key") ? k.split(":").join(":key:") : k;
6
6
  const AliasSortingPlugin = defineHeadPlugin({
package/dist/utils.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { D as DupeableTags, H as HasElementTags, M as MetaTagsArrayable, b as ScriptNetworkEvents, S as SelfClosingTags, a as TagConfigKeys, T as TagsWithInnerContent, U as UniqueTags, c as UsesMergeStrategy, V as ValidHeadTags } from './shared/unhead.yem5I2v_.mjs';
2
- export { d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, a as normalizeProps, w as walkResolver } from './shared/unhead.Di5OD67x.mjs';
2
+ export { d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, a as normalizeProps, w as walkResolver } from './shared/unhead.BpRRHAhY.mjs';
3
3
  export { r as resolveMetaKeyType, a as resolveMetaKeyValue, b as resolvePackedMetaObjectValue, u as unpackMeta } from './shared/unhead.DQc16pHI.mjs';
4
4
  export { s as sortTags, t as tagWeight } from './shared/unhead.DZbvapt-.mjs';
5
- export { p as processTemplateParams } from './shared/unhead.C13swrCa.mjs';
5
+ export { p as processTemplateParams } from './shared/unhead.BYvz9V1x.mjs';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "2.0.12",
4
+ "version": "2.0.14",
5
5
  "description": "Full-stack <head> manager built for any framework.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",