@unhead/vue 1.0.22 → 1.1.0
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 +45 -29
- package/dist/index.d.ts +117 -30
- package/dist/index.mjs +44 -31
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -137,28 +137,21 @@ function serverUseHead(input, options = {}) {
|
|
|
137
137
|
return head.push(input, options);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
function
|
|
141
|
-
|
|
140
|
+
function useHead(input, options = {}) {
|
|
141
|
+
const head = injectHead();
|
|
142
|
+
if (head) {
|
|
143
|
+
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
144
|
+
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
145
|
+
return;
|
|
146
|
+
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
147
|
+
}
|
|
142
148
|
}
|
|
143
|
-
const useServerTagTitle = (title) => useServerHead({ title });
|
|
144
|
-
const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
|
|
145
|
-
const useServerTagMeta = (meta) => useServerHead({ meta: shared.asArray(meta) });
|
|
146
|
-
const useServerTagMetaFlat = (meta) => {
|
|
147
|
-
const input = vue.ref({});
|
|
148
|
-
vue.watchEffect(() => {
|
|
149
|
-
input.value = unhead.unpackMeta(resolveUnrefHeadInput(meta));
|
|
150
|
-
});
|
|
151
|
-
return useServerHead({ meta: input });
|
|
152
|
-
};
|
|
153
|
-
const useServerTagLink = (link) => useServerHead({ link: shared.asArray(link) });
|
|
154
|
-
const useServerTagScript = (script) => useServerHead({ script: shared.asArray(script) });
|
|
155
|
-
const useServerTagStyle = (style) => useServerHead({ style: shared.asArray(style) });
|
|
156
|
-
const useServerTagNoscript = (noscript) => useServerHead({ noscript: shared.asArray(noscript) });
|
|
157
|
-
const useServerTagBase = (base) => useServerHead({ base });
|
|
158
|
-
const useServerHtmlAttrs = (attrs) => useServerHead({ htmlAttrs: attrs });
|
|
159
|
-
const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
160
149
|
|
|
161
|
-
|
|
150
|
+
function useHeadSafe(input, options = {}) {
|
|
151
|
+
return useHead(input, { ...options, transform: unhead.whitelistSafeInput });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const useSeoMeta = (input, options) => {
|
|
162
155
|
const headInput = vue.ref({});
|
|
163
156
|
vue.watchEffect(() => {
|
|
164
157
|
const resolvedMeta = resolveUnrefHeadInput(input);
|
|
@@ -169,18 +162,21 @@ const useSeoMeta = (input) => {
|
|
|
169
162
|
meta: unhead.unpackMeta(meta)
|
|
170
163
|
};
|
|
171
164
|
});
|
|
172
|
-
return useHead(headInput);
|
|
165
|
+
return useHead(headInput, options);
|
|
173
166
|
};
|
|
174
167
|
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
if (head) {
|
|
178
|
-
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
179
|
-
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
180
|
-
return;
|
|
181
|
-
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
182
|
-
}
|
|
168
|
+
function useServerHead(input, options = {}) {
|
|
169
|
+
return useHead(input, { ...options, mode: "server" });
|
|
183
170
|
}
|
|
171
|
+
|
|
172
|
+
function useServerHeadSafe(input, options = {}) {
|
|
173
|
+
return useHeadSafe(input, { ...options, mode: "server" });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function useServerSeoMeta(input, options) {
|
|
177
|
+
return useSeoMeta(input, { ...options || {}, mode: "server" });
|
|
178
|
+
}
|
|
179
|
+
|
|
184
180
|
const useTagTitle = (title) => useHead({ title });
|
|
185
181
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
|
186
182
|
const useTagMeta = (meta) => useHead({ meta: shared.asArray(meta) });
|
|
@@ -198,6 +194,23 @@ const useTagNoscript = (noscript) => useHead({ noscript: shared.asArray(noscript
|
|
|
198
194
|
const useTagBase = (base) => useHead({ base });
|
|
199
195
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
200
196
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
197
|
+
const useServerTagTitle = (title) => useServerHead({ title });
|
|
198
|
+
const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
|
|
199
|
+
const useServerTagMeta = (meta) => useServerHead({ meta: shared.asArray(meta) });
|
|
200
|
+
const useServerTagMetaFlat = (meta) => {
|
|
201
|
+
const input = vue.ref({});
|
|
202
|
+
vue.watchEffect(() => {
|
|
203
|
+
input.value = unhead.unpackMeta(resolveUnrefHeadInput(meta));
|
|
204
|
+
});
|
|
205
|
+
return useServerHead({ meta: input });
|
|
206
|
+
};
|
|
207
|
+
const useServerTagLink = (link) => useServerHead({ link: shared.asArray(link) });
|
|
208
|
+
const useServerTagScript = (script) => useServerHead({ script: shared.asArray(script) });
|
|
209
|
+
const useServerTagStyle = (style) => useServerHead({ style: shared.asArray(style) });
|
|
210
|
+
const useServerTagNoscript = (noscript) => useServerHead({ noscript: shared.asArray(noscript) });
|
|
211
|
+
const useServerTagBase = (base) => useServerHead({ base });
|
|
212
|
+
const useServerHtmlAttrs = (attrs) => useServerHead({ htmlAttrs: attrs });
|
|
213
|
+
const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
201
214
|
|
|
202
215
|
const coreComposableNames = [
|
|
203
216
|
"injectHead"
|
|
@@ -217,11 +230,14 @@ exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
|
|
|
217
230
|
exports.unheadVueComposablesImports = unheadVueComposablesImports;
|
|
218
231
|
exports.useBodyAttrs = useBodyAttrs;
|
|
219
232
|
exports.useHead = useHead;
|
|
233
|
+
exports.useHeadSafe = useHeadSafe;
|
|
220
234
|
exports.useHtmlAttrs = useHtmlAttrs;
|
|
221
235
|
exports.useSeoMeta = useSeoMeta;
|
|
222
236
|
exports.useServerBodyAttrs = useServerBodyAttrs;
|
|
223
237
|
exports.useServerHead = useServerHead;
|
|
238
|
+
exports.useServerHeadSafe = useServerHeadSafe;
|
|
224
239
|
exports.useServerHtmlAttrs = useServerHtmlAttrs;
|
|
240
|
+
exports.useServerSeoMeta = useServerSeoMeta;
|
|
225
241
|
exports.useServerTagBase = useServerTagBase;
|
|
226
242
|
exports.useServerTagLink = useServerTagLink;
|
|
227
243
|
exports.useServerTagMeta = useServerTagMeta;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createHeadCore } from 'unhead';
|
|
2
2
|
import * as _unhead_schema from '@unhead/schema';
|
|
3
|
-
import { 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,
|
|
3
|
+
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, 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, SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, Unhead, CreateHeadOptions, HeadEntryOptions, ActiveHeadEntry, MetaFlatInput } from '@unhead/schema';
|
|
4
4
|
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
5
5
|
import { ComputedRef, Ref, Plugin } from 'vue';
|
|
6
6
|
|
|
@@ -50,6 +50,10 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
50
50
|
* Generate the title from a template.
|
|
51
51
|
*/
|
|
52
52
|
titleTemplate?: TitleTemplate;
|
|
53
|
+
/**
|
|
54
|
+
* Variables used to substitute in the title and meta content.
|
|
55
|
+
*/
|
|
56
|
+
templateParams?: MaybeComputedRefEntries<Record<string, string>>;
|
|
53
57
|
/**
|
|
54
58
|
* The <base> HTML element specifies the base URL to use for all relative URLs in a document.
|
|
55
59
|
* There can be only one <base> element in a document.
|
|
@@ -77,20 +81,20 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
77
81
|
*
|
|
78
82
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
|
|
79
83
|
*/
|
|
80
|
-
style?: MaybeComputedRef<Style<E['style']>[]>;
|
|
84
|
+
style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
|
|
81
85
|
/**
|
|
82
86
|
* The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
|
|
83
87
|
*
|
|
84
88
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
|
|
85
89
|
*/
|
|
86
|
-
script?: MaybeComputedRef<Script<E['script']>[]>;
|
|
90
|
+
script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
|
|
87
91
|
/**
|
|
88
92
|
* The <noscript> HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
|
|
89
93
|
* or if scripting is currently turned off in the browser.
|
|
90
94
|
*
|
|
91
95
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
|
|
92
96
|
*/
|
|
93
|
-
noscript?: MaybeComputedRef<Noscript<E['noscript']>[]>;
|
|
97
|
+
noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
|
|
94
98
|
/**
|
|
95
99
|
* Attributes for the <html> HTML element.
|
|
96
100
|
*
|
|
@@ -106,6 +110,16 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
106
110
|
}
|
|
107
111
|
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
|
108
112
|
|
|
113
|
+
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
114
|
+
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
115
|
+
link?: MaybeComputedRefEntries<SafeLink>[];
|
|
116
|
+
noscript?: MaybeComputedRefEntries<SafeNoscript>[];
|
|
117
|
+
script?: MaybeComputedRefEntries<SafeScript>[];
|
|
118
|
+
htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
|
|
119
|
+
bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
|
|
120
|
+
}
|
|
121
|
+
type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
|
|
122
|
+
|
|
109
123
|
declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
|
|
110
124
|
|
|
111
125
|
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
@@ -121,40 +135,113 @@ declare const VueReactiveUseHeadPlugin: () => _unhead_schema.HeadPlugin;
|
|
|
121
135
|
|
|
122
136
|
declare const Vue2ProvideUnheadPlugin: Plugin;
|
|
123
137
|
|
|
124
|
-
declare function
|
|
125
|
-
|
|
126
|
-
declare
|
|
127
|
-
declare const useServerTagMeta: (meta: Arrayable<Meta>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
128
|
-
declare const useServerTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
129
|
-
declare const useServerTagLink: (link: Arrayable<Link>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
130
|
-
declare const useServerTagScript: (script: Arrayable<Script>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
131
|
-
declare const useServerTagStyle: (style: Arrayable<Style>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
132
|
-
declare const useServerTagNoscript: (noscript: Arrayable<Noscript>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
133
|
-
declare const useServerTagBase: (base: ReactiveHead['base']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
134
|
-
declare const useServerHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
135
|
-
declare const useServerBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
138
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
139
|
+
|
|
140
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
136
141
|
|
|
137
142
|
type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
138
143
|
title?: ReactiveHead['title'];
|
|
139
144
|
titleTemplate?: ReactiveHead['titleTemplate'];
|
|
140
145
|
};
|
|
141
|
-
declare const useSeoMeta: (input: UseSeoMetaInput) => ActiveHeadEntry<any> | void;
|
|
146
|
+
declare const useSeoMeta: (input: UseSeoMetaInput, options?: HeadEntryOptions) => ActiveHeadEntry<any> | void;
|
|
142
147
|
|
|
143
|
-
declare function
|
|
144
|
-
|
|
145
|
-
declare
|
|
146
|
-
|
|
147
|
-
declare
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
declare const
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadInput<T>>;
|
|
149
|
+
|
|
150
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
|
|
151
|
+
|
|
152
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use `useHead`
|
|
156
|
+
*/
|
|
157
|
+
declare const useTagTitle: (title: ReactiveHead['title']) => ActiveHeadEntry<any> | void;
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated Use `useHead`
|
|
160
|
+
*/
|
|
161
|
+
declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => ActiveHeadEntry<any> | void;
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated Use `useHead`
|
|
164
|
+
*/
|
|
165
|
+
declare const useTagMeta: (meta: Arrayable<Meta>) => ActiveHeadEntry<any> | void;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use `useHead`
|
|
168
|
+
*/
|
|
169
|
+
declare const useTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => ActiveHeadEntry<any> | void;
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Use `useHead`
|
|
172
|
+
*/
|
|
173
|
+
declare const useTagLink: (link: Arrayable<Link>) => ActiveHeadEntry<any> | void;
|
|
174
|
+
/**
|
|
175
|
+
* @deprecated Use `useHead`
|
|
176
|
+
*/
|
|
177
|
+
declare const useTagScript: (script: Arrayable<Script>) => ActiveHeadEntry<any> | void;
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated Use `useHead`
|
|
180
|
+
*/
|
|
181
|
+
declare const useTagStyle: (style: Arrayable<Style>) => ActiveHeadEntry<any> | void;
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated Use `useHead`
|
|
184
|
+
*/
|
|
185
|
+
declare const useTagNoscript: (noscript: Arrayable<Noscript>) => ActiveHeadEntry<any> | void;
|
|
186
|
+
/**
|
|
187
|
+
* @deprecated Use `useHead`
|
|
188
|
+
*/
|
|
189
|
+
declare const useTagBase: (base: ReactiveHead['base']) => ActiveHeadEntry<any> | void;
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated Use `useHead`
|
|
192
|
+
*/
|
|
193
|
+
declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => ActiveHeadEntry<any> | void;
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated Use `useHead`
|
|
196
|
+
*/
|
|
197
|
+
declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => ActiveHeadEntry<any> | void;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated Use `useHead`
|
|
200
|
+
*/
|
|
201
|
+
declare const useServerTagTitle: (title: ReactiveHead['title']) => ActiveHeadEntry<any> | void;
|
|
202
|
+
/**
|
|
203
|
+
* @deprecated Use `useHead`
|
|
204
|
+
*/
|
|
205
|
+
declare const useServerTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => ActiveHeadEntry<any> | void;
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated Use `useHead`
|
|
208
|
+
*/
|
|
209
|
+
declare const useServerTagMeta: (meta: Arrayable<Meta>) => ActiveHeadEntry<any> | void;
|
|
210
|
+
/**
|
|
211
|
+
* @deprecated Use `useHead`
|
|
212
|
+
*/
|
|
213
|
+
declare const useServerTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => ActiveHeadEntry<any> | void;
|
|
214
|
+
/**
|
|
215
|
+
* @deprecated Use `useHead`
|
|
216
|
+
*/
|
|
217
|
+
declare const useServerTagLink: (link: Arrayable<Link>) => ActiveHeadEntry<any> | void;
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated Use `useHead`
|
|
220
|
+
*/
|
|
221
|
+
declare const useServerTagScript: (script: Arrayable<Script>) => ActiveHeadEntry<any> | void;
|
|
222
|
+
/**
|
|
223
|
+
* @deprecated Use `useHead`
|
|
224
|
+
*/
|
|
225
|
+
declare const useServerTagStyle: (style: Arrayable<Style>) => ActiveHeadEntry<any> | void;
|
|
226
|
+
/**
|
|
227
|
+
* @deprecated Use `useHead`
|
|
228
|
+
*/
|
|
229
|
+
declare const useServerTagNoscript: (noscript: Arrayable<Noscript>) => ActiveHeadEntry<any> | void;
|
|
230
|
+
/**
|
|
231
|
+
* @deprecated Use `useHead`
|
|
232
|
+
*/
|
|
233
|
+
declare const useServerTagBase: (base: ReactiveHead['base']) => ActiveHeadEntry<any> | void;
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated Use `useHead`
|
|
236
|
+
*/
|
|
237
|
+
declare const useServerHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => ActiveHeadEntry<any> | void;
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated Use `useHead`
|
|
240
|
+
*/
|
|
241
|
+
declare const useServerBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => ActiveHeadEntry<any> | void;
|
|
155
242
|
|
|
156
243
|
declare const unheadVueComposablesImports: {
|
|
157
244
|
'@unhead/vue': string[];
|
|
158
245
|
};
|
|
159
246
|
|
|
160
|
-
export { Arrayable, Base, BodyAttributes, HtmlAttributes, Link, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefOrPromise, MaybeReadonlyRef, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, VueReactiveUseHeadPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useBodyAttrs, useHead, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
|
247
|
+
export { Arrayable, Base, BodyAttr, BodyAttributes, HeadSafe, HtmlAttr, HtmlAttributes, Link, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefOrPromise, MaybeReadonlyRef, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, VueReactiveUseHeadPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useBodyAttrs, useHead, useHeadSafe, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHeadSafe, useServerHtmlAttrs, useServerSeoMeta, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getActiveHead, createHead as createHead$1, unpackMeta, composableNames } from 'unhead';
|
|
1
|
+
import { getActiveHead, createHead as createHead$1, whitelistSafeInput, unpackMeta, composableNames } from 'unhead';
|
|
2
2
|
export { createHeadCore } from 'unhead';
|
|
3
3
|
import { unref, isRef, version, getCurrentInstance, inject, nextTick, ref, watchEffect, watch, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
|
|
4
4
|
import { HasElementTags, defineHeadPlugin, asArray } from '@unhead/shared';
|
|
@@ -136,28 +136,21 @@ function serverUseHead(input, options = {}) {
|
|
|
136
136
|
return head.push(input, options);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
function
|
|
140
|
-
|
|
139
|
+
function useHead(input, options = {}) {
|
|
140
|
+
const head = injectHead();
|
|
141
|
+
if (head) {
|
|
142
|
+
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
143
|
+
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
144
|
+
return;
|
|
145
|
+
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
146
|
+
}
|
|
141
147
|
}
|
|
142
|
-
const useServerTagTitle = (title) => useServerHead({ title });
|
|
143
|
-
const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
|
|
144
|
-
const useServerTagMeta = (meta) => useServerHead({ meta: asArray(meta) });
|
|
145
|
-
const useServerTagMetaFlat = (meta) => {
|
|
146
|
-
const input = ref({});
|
|
147
|
-
watchEffect(() => {
|
|
148
|
-
input.value = unpackMeta(resolveUnrefHeadInput(meta));
|
|
149
|
-
});
|
|
150
|
-
return useServerHead({ meta: input });
|
|
151
|
-
};
|
|
152
|
-
const useServerTagLink = (link) => useServerHead({ link: asArray(link) });
|
|
153
|
-
const useServerTagScript = (script) => useServerHead({ script: asArray(script) });
|
|
154
|
-
const useServerTagStyle = (style) => useServerHead({ style: asArray(style) });
|
|
155
|
-
const useServerTagNoscript = (noscript) => useServerHead({ noscript: asArray(noscript) });
|
|
156
|
-
const useServerTagBase = (base) => useServerHead({ base });
|
|
157
|
-
const useServerHtmlAttrs = (attrs) => useServerHead({ htmlAttrs: attrs });
|
|
158
|
-
const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
159
148
|
|
|
160
|
-
|
|
149
|
+
function useHeadSafe(input, options = {}) {
|
|
150
|
+
return useHead(input, { ...options, transform: whitelistSafeInput });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const useSeoMeta = (input, options) => {
|
|
161
154
|
const headInput = ref({});
|
|
162
155
|
watchEffect(() => {
|
|
163
156
|
const resolvedMeta = resolveUnrefHeadInput(input);
|
|
@@ -168,18 +161,21 @@ const useSeoMeta = (input) => {
|
|
|
168
161
|
meta: unpackMeta(meta)
|
|
169
162
|
};
|
|
170
163
|
});
|
|
171
|
-
return useHead(headInput);
|
|
164
|
+
return useHead(headInput, options);
|
|
172
165
|
};
|
|
173
166
|
|
|
174
|
-
function
|
|
175
|
-
|
|
176
|
-
if (head) {
|
|
177
|
-
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
178
|
-
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
179
|
-
return;
|
|
180
|
-
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
181
|
-
}
|
|
167
|
+
function useServerHead(input, options = {}) {
|
|
168
|
+
return useHead(input, { ...options, mode: "server" });
|
|
182
169
|
}
|
|
170
|
+
|
|
171
|
+
function useServerHeadSafe(input, options = {}) {
|
|
172
|
+
return useHeadSafe(input, { ...options, mode: "server" });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function useServerSeoMeta(input, options) {
|
|
176
|
+
return useSeoMeta(input, { ...options || {}, mode: "server" });
|
|
177
|
+
}
|
|
178
|
+
|
|
183
179
|
const useTagTitle = (title) => useHead({ title });
|
|
184
180
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
|
185
181
|
const useTagMeta = (meta) => useHead({ meta: asArray(meta) });
|
|
@@ -197,6 +193,23 @@ const useTagNoscript = (noscript) => useHead({ noscript: asArray(noscript) });
|
|
|
197
193
|
const useTagBase = (base) => useHead({ base });
|
|
198
194
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
199
195
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
196
|
+
const useServerTagTitle = (title) => useServerHead({ title });
|
|
197
|
+
const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
|
|
198
|
+
const useServerTagMeta = (meta) => useServerHead({ meta: asArray(meta) });
|
|
199
|
+
const useServerTagMetaFlat = (meta) => {
|
|
200
|
+
const input = ref({});
|
|
201
|
+
watchEffect(() => {
|
|
202
|
+
input.value = unpackMeta(resolveUnrefHeadInput(meta));
|
|
203
|
+
});
|
|
204
|
+
return useServerHead({ meta: input });
|
|
205
|
+
};
|
|
206
|
+
const useServerTagLink = (link) => useServerHead({ link: asArray(link) });
|
|
207
|
+
const useServerTagScript = (script) => useServerHead({ script: asArray(script) });
|
|
208
|
+
const useServerTagStyle = (style) => useServerHead({ style: asArray(style) });
|
|
209
|
+
const useServerTagNoscript = (noscript) => useServerHead({ noscript: asArray(noscript) });
|
|
210
|
+
const useServerTagBase = (base) => useServerHead({ base });
|
|
211
|
+
const useServerHtmlAttrs = (attrs) => useServerHead({ htmlAttrs: attrs });
|
|
212
|
+
const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
200
213
|
|
|
201
214
|
const coreComposableNames = [
|
|
202
215
|
"injectHead"
|
|
@@ -205,4 +218,4 @@ const unheadVueComposablesImports = {
|
|
|
205
218
|
"@unhead/vue": [...coreComposableNames, ...composableNames]
|
|
206
219
|
};
|
|
207
220
|
|
|
208
|
-
export { Vue2ProvideUnheadPlugin, VueHeadMixin, VueReactiveUseHeadPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useBodyAttrs, useHead, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
|
221
|
+
export { Vue2ProvideUnheadPlugin, VueHeadMixin, VueReactiveUseHeadPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useBodyAttrs, useHead, useHeadSafe, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHeadSafe, useServerHtmlAttrs, useServerSeoMeta, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0
|
|
5
|
-
"packageManager": "pnpm@7.
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"packageManager": "pnpm@7.27.1",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"hookable": "^5.4.2",
|
|
37
|
-
"@unhead/schema": "1.0
|
|
38
|
-
"unhead": "1.0
|
|
39
|
-
"
|
|
37
|
+
"@unhead/schema": "1.1.0",
|
|
38
|
+
"@unhead/shared": "1.1.0",
|
|
39
|
+
"unhead": "1.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vue": "^3.2.47"
|