@unhead/vue 0.3.1 → 0.4.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
@@ -14,7 +14,7 @@ function resolveUnrefHeadInput(ref) {
14
14
  if (typeof root === "object") {
15
15
  return Object.fromEntries(
16
16
  Object.entries(root).map(([key, value]) => {
17
- if (key === "titleTemplate")
17
+ if (key === "titleTemplate" || key.startsWith("on"))
18
18
  return [key, vue.unref(value)];
19
19
  return [key, resolveUnrefHeadInput(value)];
20
20
  })
@@ -27,7 +27,6 @@ function asArray(value) {
27
27
  }
28
28
 
29
29
  const Vue3 = vue.version.startsWith("3");
30
- vue.version.startsWith("2.");
31
30
  const IsBrowser = typeof window !== "undefined";
32
31
 
33
32
  function unpackToArray(input, options) {
@@ -220,7 +219,9 @@ const useServerHtmlAttrs = (attrs) => useServerHead({ htmlAttrs: attrs });
220
219
  const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
221
220
 
222
221
  function useHead(input, options = {}) {
223
- if (options.mode === "server" && IsBrowser || options.mode === "client" && !IsBrowser)
222
+ const head = injectHead();
223
+ const isBrowser = IsBrowser || head.resolvedOptions?.document;
224
+ if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
224
225
  return;
225
226
  IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
226
227
  }
@@ -248,7 +249,7 @@ function injectHead() {
248
249
  }
249
250
  function createHead(options = {}) {
250
251
  const plugins = [
251
- unhead.HydratesStatePlugin(),
252
+ unhead.HydrateStateFromSSRPlugin(),
252
253
  VueReactiveUseHeadPlugin(),
253
254
  ...options?.plugins || []
254
255
  ];
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolveUnref } from '@vueuse/shared';
2
2
  import { unref, version, getCurrentInstance, ref, watchEffect, watch, onBeforeUnmount, inject, nextTick } from 'vue';
3
- import { getActiveHead, HydratesStatePlugin, createHead as createHead$1, defineHeadPlugin } from 'unhead';
3
+ import { getActiveHead, HydrateStateFromSSRPlugin, createHead as createHead$1, defineHeadPlugin } from 'unhead';
4
4
  export * from '@unhead/dom';
5
5
 
6
6
  function resolveUnrefHeadInput(ref) {
@@ -12,7 +12,7 @@ function resolveUnrefHeadInput(ref) {
12
12
  if (typeof root === "object") {
13
13
  return Object.fromEntries(
14
14
  Object.entries(root).map(([key, value]) => {
15
- if (key === "titleTemplate")
15
+ if (key === "titleTemplate" || key.startsWith("on"))
16
16
  return [key, unref(value)];
17
17
  return [key, resolveUnrefHeadInput(value)];
18
18
  })
@@ -25,7 +25,6 @@ function asArray(value) {
25
25
  }
26
26
 
27
27
  const Vue3 = version.startsWith("3");
28
- version.startsWith("2.");
29
28
  const IsBrowser = typeof window !== "undefined";
30
29
 
31
30
  function unpackToArray(input, options) {
@@ -218,7 +217,9 @@ const useServerHtmlAttrs = (attrs) => useServerHead({ htmlAttrs: attrs });
218
217
  const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
219
218
 
220
219
  function useHead(input, options = {}) {
221
- if (options.mode === "server" && IsBrowser || options.mode === "client" && !IsBrowser)
220
+ const head = injectHead();
221
+ const isBrowser = IsBrowser || head.resolvedOptions?.document;
222
+ if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
222
223
  return;
223
224
  IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
224
225
  }
@@ -246,7 +247,7 @@ function injectHead() {
246
247
  }
247
248
  function createHead(options = {}) {
248
249
  const plugins = [
249
- HydratesStatePlugin(),
250
+ HydrateStateFromSSRPlugin(),
250
251
  VueReactiveUseHeadPlugin(),
251
252
  ...options?.plugins || []
252
253
  ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.4.2",
5
5
  "packageManager": "pnpm@7.14.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -33,10 +33,10 @@
33
33
  "vue": ">=2.7 || >=3"
34
34
  },
35
35
  "dependencies": {
36
- "@unhead/dom": "0.3.1",
37
- "@unhead/schema": "0.3.1",
36
+ "@unhead/dom": "0.4.2",
37
+ "@unhead/schema": "0.4.2",
38
38
  "@vueuse/shared": "latest",
39
- "unhead": "0.3.1"
39
+ "unhead": "0.4.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "vue": "^3.2.42"