@unhead/vue 1.0.18 → 1.0.20

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
@@ -887,6 +887,7 @@ const MetaPackingSchema = {
887
887
  keyValueSeparator: ":"
888
888
  }
889
889
  },
890
+ // Pragma directives
890
891
  contentSecurityPolicy: {
891
892
  unpack: {
892
893
  keyValueSeparator: " ",
@@ -901,9 +902,15 @@ const MetaPackingSchema = {
901
902
  msapplicationTileImage: {
902
903
  keyValue: "msapplication-TileImage"
903
904
  },
905
+ /**
906
+ * Tile colour for windows
907
+ */
904
908
  msapplicationTileColor: {
905
909
  keyValue: "msapplication-TileColor"
906
910
  },
911
+ /**
912
+ * URL of a config for windows tile.
913
+ */
907
914
  msapplicationConfig: {
908
915
  keyValue: "msapplication-Config"
909
916
  },
@@ -927,7 +934,34 @@ function resolveMetaKeyType(key) {
927
934
  return PropertyPrefixKeys.test(key) ? "property" : MetaPackingSchema[key]?.metaKey || "name";
928
935
  }
929
936
 
937
+ const ArrayableInputs = ["Image", "Video", "Audio"];
930
938
  function unpackMeta(input) {
939
+ const extras = [];
940
+ ArrayableInputs.forEach((key) => {
941
+ const ogKey = `og:${key.toLowerCase()}`;
942
+ const inputKey = `og${key}`;
943
+ const val = input[inputKey];
944
+ if (typeof val === "object") {
945
+ (Array.isArray(val) ? val : [val]).forEach((entry) => {
946
+ if (!entry)
947
+ return;
948
+ const unpackedEntry = unpackToArray(entry, {
949
+ key: "property",
950
+ value: "content",
951
+ resolveKeyData({ key: key2 }) {
952
+ return fixKeyCase(`${ogKey}${key2 !== "url" ? `:${key2}` : ""}`);
953
+ },
954
+ resolveValueData({ value }) {
955
+ return typeof value === "number" ? value.toString() : value;
956
+ }
957
+ });
958
+ extras.push(
959
+ ...unpackedEntry.sort((a, b) => a.property === ogKey ? -1 : b.property === ogKey ? 1 : 0)
960
+ );
961
+ });
962
+ delete input[inputKey];
963
+ }
964
+ });
931
965
  const meta = unpackToArray(input, {
932
966
  key({ key }) {
933
967
  return resolveMetaKeyType(key);
@@ -963,13 +997,14 @@ function unpackMeta(input) {
963
997
  return typeof value === "number" ? value.toString() : value;
964
998
  }
965
999
  });
966
- return meta.filter((v) => typeof v.content === "undefined" || v.content !== "_null");
1000
+ return [...extras, ...meta].filter((v) => typeof v.content === "undefined" || v.content !== "_null");
967
1001
  }
968
1002
 
969
- const PropertyPrefixKeys = /^(og|twitter|fb)/;
1003
+ const PropertyPrefixKeys = /^(og|fb)/;
1004
+ const ColonPrefixKeys = /^(og|twitter|fb)/;
970
1005
  function fixKeyCase(key) {
971
1006
  key = key.replace(/([A-Z])/g, "-$1").toLowerCase();
972
- if (PropertyPrefixKeys.test(key)) {
1007
+ if (ColonPrefixKeys.test(key)) {
973
1008
  key = key.replace("secure-url", "secure_url").replace(/-/g, ":");
974
1009
  }
975
1010
  return key;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _unhead_schema from '@unhead/schema';
2
- import { Head, CreateHeadOptions, Unhead, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MergeHead, BaseHtmlAttr, MaybeArray, BaseBodyAttr, HeadEntryOptions, MetaFlatInput, ActiveHeadEntry } from '@unhead/schema';
2
+ import { Head, CreateHeadOptions, Unhead, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeFunctionEntries, BodyEvents, MergeHead, BaseHtmlAttr, MaybeArray, BaseBodyAttr, HeadEntryOptions, MetaFlatInput, ActiveHeadEntry } from '@unhead/schema';
3
3
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
4
4
  import { ComputedRef, Ref, Plugin } from 'vue';
5
5
 
@@ -44,7 +44,7 @@ type Style<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Style$1<E
44
44
  type Script<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Script$1<E>>;
45
45
  type Noscript<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Noscript$1<E>>;
46
46
  type HtmlAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
47
- type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>>>;
47
+ type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeFunctionEntries<BodyEvents>>;
48
48
  interface ReactiveHead<E extends MergeHead = MergeHead> {
49
49
  /**
50
50
  * The <title> HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
package/dist/index.mjs CHANGED
@@ -885,6 +885,7 @@ const MetaPackingSchema = {
885
885
  keyValueSeparator: ":"
886
886
  }
887
887
  },
888
+ // Pragma directives
888
889
  contentSecurityPolicy: {
889
890
  unpack: {
890
891
  keyValueSeparator: " ",
@@ -899,9 +900,15 @@ const MetaPackingSchema = {
899
900
  msapplicationTileImage: {
900
901
  keyValue: "msapplication-TileImage"
901
902
  },
903
+ /**
904
+ * Tile colour for windows
905
+ */
902
906
  msapplicationTileColor: {
903
907
  keyValue: "msapplication-TileColor"
904
908
  },
909
+ /**
910
+ * URL of a config for windows tile.
911
+ */
905
912
  msapplicationConfig: {
906
913
  keyValue: "msapplication-Config"
907
914
  },
@@ -925,7 +932,34 @@ function resolveMetaKeyType(key) {
925
932
  return PropertyPrefixKeys.test(key) ? "property" : MetaPackingSchema[key]?.metaKey || "name";
926
933
  }
927
934
 
935
+ const ArrayableInputs = ["Image", "Video", "Audio"];
928
936
  function unpackMeta(input) {
937
+ const extras = [];
938
+ ArrayableInputs.forEach((key) => {
939
+ const ogKey = `og:${key.toLowerCase()}`;
940
+ const inputKey = `og${key}`;
941
+ const val = input[inputKey];
942
+ if (typeof val === "object") {
943
+ (Array.isArray(val) ? val : [val]).forEach((entry) => {
944
+ if (!entry)
945
+ return;
946
+ const unpackedEntry = unpackToArray(entry, {
947
+ key: "property",
948
+ value: "content",
949
+ resolveKeyData({ key: key2 }) {
950
+ return fixKeyCase(`${ogKey}${key2 !== "url" ? `:${key2}` : ""}`);
951
+ },
952
+ resolveValueData({ value }) {
953
+ return typeof value === "number" ? value.toString() : value;
954
+ }
955
+ });
956
+ extras.push(
957
+ ...unpackedEntry.sort((a, b) => a.property === ogKey ? -1 : b.property === ogKey ? 1 : 0)
958
+ );
959
+ });
960
+ delete input[inputKey];
961
+ }
962
+ });
929
963
  const meta = unpackToArray(input, {
930
964
  key({ key }) {
931
965
  return resolveMetaKeyType(key);
@@ -961,13 +995,14 @@ function unpackMeta(input) {
961
995
  return typeof value === "number" ? value.toString() : value;
962
996
  }
963
997
  });
964
- return meta.filter((v) => typeof v.content === "undefined" || v.content !== "_null");
998
+ return [...extras, ...meta].filter((v) => typeof v.content === "undefined" || v.content !== "_null");
965
999
  }
966
1000
 
967
- const PropertyPrefixKeys = /^(og|twitter|fb)/;
1001
+ const PropertyPrefixKeys = /^(og|fb)/;
1002
+ const ColonPrefixKeys = /^(og|twitter|fb)/;
968
1003
  function fixKeyCase(key) {
969
1004
  key = key.replace(/([A-Z])/g, "-$1").toLowerCase();
970
- if (PropertyPrefixKeys.test(key)) {
1005
+ if (ColonPrefixKeys.test(key)) {
971
1006
  key = key.replace("secure-url", "secure_url").replace(/-/g, ":");
972
1007
  }
973
1008
  return key;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "1.0.18",
4
+ "version": "1.0.20",
5
5
  "packageManager": "pnpm@7.25.1",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "hookable": "^5.4.2",
37
- "@unhead/schema": "1.0.18"
37
+ "@unhead/schema": "1.0.20"
38
38
  },
39
39
  "devDependencies": {
40
40
  "vue": "^3.2.45",
41
- "unhead": "1.0.18"
41
+ "unhead": "1.0.20"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "unbuild .",