mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-05-17 06:29:38 +03:00
chore(release): 3.0.0-alpha.7
This commit is contained in:
@@ -2,6 +2,18 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [3.0.0-alpha.7](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2021-05-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* check if DOM is still loading before cleanup ([1785d4f](https://github.com/nuxt/vue-meta/commit/1785d4fef6b2c2adaa645e44419c3da883863562))
|
||||
* export ssr type declarion into ssr folder ([01e4aed](https://github.com/nuxt/vue-meta/commit/01e4aed34034984e5a523d77db9bd79e66418678))
|
||||
* get keyAttribute _either_ from section or tag config ([e551fe4](https://github.com/nuxt/vue-meta/commit/e551fe46fe6f81726f6f6ce9734aedccdc0753df))
|
||||
* get keyAttribute either from section or tag config ([3b3d3f4](https://github.com/nuxt/vue-meta/commit/3b3d3f4397eb83003c5d1dd69ec862b39c9fbf37))
|
||||
* SSR active, dont use global active var due to runInNewContext: false ([#668](https://github.com/nuxt/vue-meta/issues/668)) ([6593e92](https://github.com/nuxt/vue-meta/commit/6593e9272dea7585cb72b925beafad2020c623db))
|
||||
* use document.title to update title on the client ([88d57e7](https://github.com/nuxt/vue-meta/commit/88d57e71993bab8866cc9de22534b39ca01dbf33))
|
||||
|
||||
## [3.0.0-alpha.6](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2021-05-17)
|
||||
|
||||
|
||||
|
||||
Vendored
+24
-10
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.6
|
||||
* vue-meta v3.0.0-alpha.7
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -518,6 +518,7 @@ function renderGroup(context, key, data, config) {
|
||||
}
|
||||
return renderTag(context, key, data[childKey], config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
@@ -529,6 +530,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
.map((child) => {
|
||||
return renderTag(context, key, child, config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
const { tag = config.tag || key } = data;
|
||||
@@ -545,7 +547,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
if (isArray(data)) {
|
||||
return data.map(({ vnode }) => vnode);
|
||||
}
|
||||
return data.vnode;
|
||||
return data && data.vnode;
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -594,8 +596,9 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
content = getSlotContent(context, slotName, content, data);
|
||||
}
|
||||
else {
|
||||
const { nameless, keyAttribute } = config;
|
||||
const { nameless } = config;
|
||||
if (!nameless) {
|
||||
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
|
||||
if (keyAttribute) {
|
||||
attributes[keyAttribute] = fullName;
|
||||
}
|
||||
@@ -607,6 +610,10 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
const finalTag = groupConfig && groupConfig.tagNamespace
|
||||
? `${groupConfig.tagNamespace}:${tag}`
|
||||
: tag;
|
||||
if (finalTag === 'title' && !context.isSSR) {
|
||||
document.title = content;
|
||||
return;
|
||||
}
|
||||
// console.info('FINAL TAG', finalTag)
|
||||
// console.log(' ATTRIBUTES', attributes)
|
||||
// console.log(' CONTENT', content)
|
||||
@@ -766,7 +773,6 @@ const MetainfoImpl = vue.defineComponent({
|
||||
const Metainfo = MetainfoImpl;
|
||||
|
||||
const ssrAttribute = 'data-vm-ssr';
|
||||
const active = vue.reactive({});
|
||||
function addVnode(isSSR, teleports, to, vnodes) {
|
||||
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
|
||||
if (!isSSR) {
|
||||
@@ -806,7 +812,7 @@ class MetaManager {
|
||||
install(app) {
|
||||
app.component('Metainfo', Metainfo);
|
||||
app.config.globalProperties.$metaManager = this;
|
||||
app.provide(metaActiveKey, active);
|
||||
app.provide(metaActiveKey, this.target.context.active);
|
||||
}
|
||||
addMeta(metadata, vm) {
|
||||
if (!vm) {
|
||||
@@ -865,20 +871,27 @@ class MetaManager {
|
||||
}
|
||||
}
|
||||
render({ slots } = {}) {
|
||||
const active = this.target.context.active;
|
||||
// TODO: clean this method
|
||||
const { isSSR } = this;
|
||||
// cleanup ssr tags if not yet done
|
||||
if (!isSSR && !this.ssrCleanedUp) {
|
||||
this.ssrCleanedUp = true;
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const cleanUpSSR = () => {
|
||||
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
|
||||
if (ssrTags && ssrTags.length) {
|
||||
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
|
||||
}
|
||||
}, { once: true });
|
||||
};
|
||||
if (document.readyState === 'loading') {
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
|
||||
}
|
||||
else {
|
||||
cleanUpSSR();
|
||||
}
|
||||
}
|
||||
const teleports = {};
|
||||
for (const key in active) {
|
||||
@@ -927,6 +940,7 @@ MetaManager.create = (isSSR, config, resolver) => {
|
||||
}
|
||||
return resolver.resolve(options, contexts, active, key, pathSegments);
|
||||
};
|
||||
const active = vue.reactive({});
|
||||
const mergedObject = createMergedObject(resolve, active);
|
||||
// TODO: validate resolver
|
||||
const manager = new MetaManager(isSSR, config, mergedObject, resolver);
|
||||
|
||||
Vendored
+24
-10
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.6
|
||||
* vue-meta v3.0.0-alpha.7
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -507,6 +507,7 @@ function renderGroup(context, key, data, config) {
|
||||
}
|
||||
return renderTag(context, key, data[childKey], config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
@@ -518,6 +519,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
.map((child) => {
|
||||
return renderTag(context, key, child, config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
const { tag = config.tag || key } = data;
|
||||
@@ -534,7 +536,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
if (isArray(data)) {
|
||||
return data.map(({ vnode }) => vnode);
|
||||
}
|
||||
return data.vnode;
|
||||
return data && data.vnode;
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -583,8 +585,9 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
content = getSlotContent(context, slotName, content, data);
|
||||
}
|
||||
else {
|
||||
const { nameless, keyAttribute } = config;
|
||||
const { nameless } = config;
|
||||
if (!nameless) {
|
||||
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
|
||||
if (keyAttribute) {
|
||||
attributes[keyAttribute] = fullName;
|
||||
}
|
||||
@@ -596,6 +599,10 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
const finalTag = groupConfig && groupConfig.tagNamespace
|
||||
? `${groupConfig.tagNamespace}:${tag}`
|
||||
: tag;
|
||||
if (finalTag === 'title' && !context.isSSR) {
|
||||
document.title = content;
|
||||
return;
|
||||
}
|
||||
// console.info('FINAL TAG', finalTag)
|
||||
// console.log(' ATTRIBUTES', attributes)
|
||||
// console.log(' CONTENT', content)
|
||||
@@ -746,7 +753,6 @@ const MetainfoImpl = vue.defineComponent({
|
||||
const Metainfo = MetainfoImpl;
|
||||
|
||||
const ssrAttribute = 'data-vm-ssr';
|
||||
const active = vue.reactive({});
|
||||
function addVnode(isSSR, teleports, to, vnodes) {
|
||||
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
|
||||
if (!isSSR) {
|
||||
@@ -786,7 +792,7 @@ class MetaManager {
|
||||
install(app) {
|
||||
app.component('Metainfo', Metainfo);
|
||||
app.config.globalProperties.$metaManager = this;
|
||||
app.provide(metaActiveKey, active);
|
||||
app.provide(metaActiveKey, this.target.context.active);
|
||||
}
|
||||
addMeta(metadata, vm) {
|
||||
if (!vm) {
|
||||
@@ -845,20 +851,27 @@ class MetaManager {
|
||||
}
|
||||
}
|
||||
render({ slots } = {}) {
|
||||
const active = this.target.context.active;
|
||||
// TODO: clean this method
|
||||
const { isSSR } = this;
|
||||
// cleanup ssr tags if not yet done
|
||||
if (!isSSR && !this.ssrCleanedUp) {
|
||||
this.ssrCleanedUp = true;
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const cleanUpSSR = () => {
|
||||
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
|
||||
if (ssrTags && ssrTags.length) {
|
||||
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
|
||||
}
|
||||
}, { once: true });
|
||||
};
|
||||
if (document.readyState === 'loading') {
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
|
||||
}
|
||||
else {
|
||||
cleanUpSSR();
|
||||
}
|
||||
}
|
||||
const teleports = {};
|
||||
for (const key in active) {
|
||||
@@ -907,6 +920,7 @@ MetaManager.create = (isSSR, config, resolver) => {
|
||||
}
|
||||
return resolver.resolve(options, contexts, active, key, pathSegments);
|
||||
};
|
||||
const active = vue.reactive({});
|
||||
const mergedObject = createMergedObject(resolve, active);
|
||||
// TODO: validate resolver
|
||||
const manager = new MetaManager(isSSR, config, mergedObject, resolver);
|
||||
|
||||
Vendored
+4
-2
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.6
|
||||
* vue-meta v3.0.0-alpha.7
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -96,6 +96,8 @@ declare type MetaTagsConfig = {
|
||||
};
|
||||
|
||||
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
||||
declare type Truthy<T> = T extends undefined | void | null | false | 0 | '' ? never : T;
|
||||
declare type ExcludesFalsy = <T>(x: T) => x is Truthy<T>;
|
||||
declare type TODO = any;
|
||||
/**
|
||||
* Proxied meta source for tracking changes and updating the active meta daa
|
||||
@@ -214,4 +216,4 @@ declare function getCurrentManager(vm?: ComponentInternalInstance): MetaManager
|
||||
declare function useMeta(source: MetaSource, manager?: MetaManager): MetaProxy;
|
||||
declare function useActiveMeta(): MetaActive;
|
||||
|
||||
export { MetaActive, MetaConfig, MetaConfigSection, MetaConfigSectionAttribute, MetaConfigSectionGroup, MetaConfigSectionKey, MetaConfigSectionTag, MetaGroupConfig, MetaGuardRemoved, MetaGuards, MetaProxy, MetaRenderContext, MetaRendered, MetaRenderedNode, MetaResolveContext, MetaResolveSetup, MetaResolver, MetaResolverSetup, MetaSource, MetaSourceProxy, MetaTagConfig, MetaTagConfigKey, MetaTagName, MetaTagsConfig, MetaTeleports, Modify, SlotScopeProperties, TODO, createMetaManager, deepest_d as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };
|
||||
export { ExcludesFalsy, MetaActive, MetaConfig, MetaConfigSection, MetaConfigSectionAttribute, MetaConfigSectionGroup, MetaConfigSectionKey, MetaConfigSectionTag, MetaGroupConfig, MetaGuardRemoved, MetaGuards, MetaProxy, MetaRenderContext, MetaRendered, MetaRenderedNode, MetaResolveContext, MetaResolveSetup, MetaResolver, MetaResolverSetup, MetaSource, MetaSourceProxy, MetaTagConfig, MetaTagConfigKey, MetaTagName, MetaTagsConfig, MetaTeleports, Modify, SlotScopeProperties, TODO, Truthy, createMetaManager, deepest_d as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };
|
||||
|
||||
Vendored
+25
-11
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.6
|
||||
* vue-meta v3.0.0-alpha.7
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, reactive, onUnmounted, Teleport, Comment } from 'vue';
|
||||
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, onUnmounted, Teleport, reactive, Comment } from 'vue';
|
||||
|
||||
const resolveOption = (predicament, initialValue) => (options, contexts) => {
|
||||
let resolvedIndex = -1;
|
||||
@@ -514,6 +514,7 @@ function renderGroup(context, key, data, config) {
|
||||
}
|
||||
return renderTag(context, key, data[childKey], config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
@@ -525,6 +526,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
.map((child) => {
|
||||
return renderTag(context, key, child, config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
const { tag = config.tag || key } = data;
|
||||
@@ -541,7 +543,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
if (isArray(data)) {
|
||||
return data.map(({ vnode }) => vnode);
|
||||
}
|
||||
return data.vnode;
|
||||
return data && data.vnode;
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -590,8 +592,9 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
content = getSlotContent(context, slotName, content, data);
|
||||
}
|
||||
else {
|
||||
const { nameless, keyAttribute } = config;
|
||||
const { nameless } = config;
|
||||
if (!nameless) {
|
||||
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
|
||||
if (keyAttribute) {
|
||||
attributes[keyAttribute] = fullName;
|
||||
}
|
||||
@@ -603,6 +606,10 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
const finalTag = groupConfig && groupConfig.tagNamespace
|
||||
? `${groupConfig.tagNamespace}:${tag}`
|
||||
: tag;
|
||||
if (finalTag === 'title' && !context.isSSR) {
|
||||
document.title = content;
|
||||
return;
|
||||
}
|
||||
// console.info('FINAL TAG', finalTag)
|
||||
// console.log(' ATTRIBUTES', attributes)
|
||||
// console.log(' CONTENT', content)
|
||||
@@ -762,7 +769,6 @@ const MetainfoImpl = defineComponent({
|
||||
const Metainfo = MetainfoImpl;
|
||||
|
||||
const ssrAttribute = 'data-vm-ssr';
|
||||
const active = reactive({});
|
||||
function addVnode(isSSR, teleports, to, vnodes) {
|
||||
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
|
||||
if (!isSSR) {
|
||||
@@ -802,7 +808,7 @@ class MetaManager {
|
||||
install(app) {
|
||||
app.component('Metainfo', Metainfo);
|
||||
app.config.globalProperties.$metaManager = this;
|
||||
app.provide(metaActiveKey, active);
|
||||
app.provide(metaActiveKey, this.target.context.active);
|
||||
}
|
||||
addMeta(metadata, vm) {
|
||||
if (!vm) {
|
||||
@@ -861,20 +867,27 @@ class MetaManager {
|
||||
}
|
||||
}
|
||||
render({ slots } = {}) {
|
||||
const active = this.target.context.active;
|
||||
// TODO: clean this method
|
||||
const { isSSR } = this;
|
||||
// cleanup ssr tags if not yet done
|
||||
if (!isSSR && !this.ssrCleanedUp) {
|
||||
this.ssrCleanedUp = true;
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const cleanUpSSR = () => {
|
||||
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
|
||||
if (ssrTags && ssrTags.length) {
|
||||
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
|
||||
}
|
||||
}, { once: true });
|
||||
};
|
||||
if (document.readyState === 'loading') {
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
|
||||
}
|
||||
else {
|
||||
cleanUpSSR();
|
||||
}
|
||||
}
|
||||
const teleports = {};
|
||||
for (const key in active) {
|
||||
@@ -923,6 +936,7 @@ MetaManager.create = (isSSR, config, resolver) => {
|
||||
}
|
||||
return resolver.resolve(options, contexts, active, key, pathSegments);
|
||||
};
|
||||
const active = reactive({});
|
||||
const mergedObject = createMergedObject(resolve, active);
|
||||
// TODO: validate resolver
|
||||
const manager = new MetaManager(isSSR, config, mergedObject, resolver);
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+25
-11
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.6
|
||||
* vue-meta v3.0.0-alpha.7
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, reactive, onUnmounted, Teleport, Comment } from 'vue';
|
||||
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, onUnmounted, Teleport, reactive, Comment } from 'vue';
|
||||
|
||||
const resolveOption = (predicament, initialValue) => (options, contexts) => {
|
||||
let resolvedIndex = -1;
|
||||
@@ -514,6 +514,7 @@ function renderGroup(context, key, data, config) {
|
||||
}
|
||||
return renderTag(context, key, data[childKey], config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
@@ -525,6 +526,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
.map((child) => {
|
||||
return renderTag(context, key, child, config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
const { tag = config.tag || key } = data;
|
||||
@@ -541,7 +543,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
if (isArray(data)) {
|
||||
return data.map(({ vnode }) => vnode);
|
||||
}
|
||||
return data.vnode;
|
||||
return data && data.vnode;
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -590,8 +592,9 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
content = getSlotContent(context, slotName, content, data);
|
||||
}
|
||||
else {
|
||||
const { nameless, keyAttribute } = config;
|
||||
const { nameless } = config;
|
||||
if (!nameless) {
|
||||
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
|
||||
if (keyAttribute) {
|
||||
attributes[keyAttribute] = fullName;
|
||||
}
|
||||
@@ -603,6 +606,10 @@ function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
const finalTag = groupConfig && groupConfig.tagNamespace
|
||||
? `${groupConfig.tagNamespace}:${tag}`
|
||||
: tag;
|
||||
if (finalTag === 'title' && !context.isSSR) {
|
||||
document.title = content;
|
||||
return;
|
||||
}
|
||||
// console.info('FINAL TAG', finalTag)
|
||||
// console.log(' ATTRIBUTES', attributes)
|
||||
// console.log(' CONTENT', content)
|
||||
@@ -762,7 +769,6 @@ const MetainfoImpl = defineComponent({
|
||||
const Metainfo = MetainfoImpl;
|
||||
|
||||
const ssrAttribute = 'data-vm-ssr';
|
||||
const active = reactive({});
|
||||
function addVnode(isSSR, teleports, to, vnodes) {
|
||||
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
|
||||
if (!isSSR) {
|
||||
@@ -802,7 +808,7 @@ class MetaManager {
|
||||
install(app) {
|
||||
app.component('Metainfo', Metainfo);
|
||||
app.config.globalProperties.$metaManager = this;
|
||||
app.provide(metaActiveKey, active);
|
||||
app.provide(metaActiveKey, this.target.context.active);
|
||||
}
|
||||
addMeta(metadata, vm) {
|
||||
if (!vm) {
|
||||
@@ -861,20 +867,27 @@ class MetaManager {
|
||||
}
|
||||
}
|
||||
render({ slots } = {}) {
|
||||
const active = this.target.context.active;
|
||||
// TODO: clean this method
|
||||
const { isSSR } = this;
|
||||
// cleanup ssr tags if not yet done
|
||||
if (!isSSR && !this.ssrCleanedUp) {
|
||||
this.ssrCleanedUp = true;
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const cleanUpSSR = () => {
|
||||
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
|
||||
if (ssrTags && ssrTags.length) {
|
||||
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
|
||||
}
|
||||
}, { once: true });
|
||||
};
|
||||
if (document.readyState === 'loading') {
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
|
||||
}
|
||||
else {
|
||||
cleanUpSSR();
|
||||
}
|
||||
}
|
||||
const teleports = {};
|
||||
for (const key in active) {
|
||||
@@ -923,6 +936,7 @@ MetaManager.create = (isSSR, config, resolver) => {
|
||||
}
|
||||
return resolver.resolve(options, contexts, active, key, pathSegments);
|
||||
};
|
||||
const active = reactive({});
|
||||
const mergedObject = createMergedObject(resolve, active);
|
||||
// TODO: validate resolver
|
||||
const manager = new MetaManager(isSSR, config, mergedObject, resolver);
|
||||
|
||||
Vendored
+24
-10
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.6
|
||||
* vue-meta v3.0.0-alpha.7
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -515,6 +515,7 @@ var VueMeta = (function (exports, vue) {
|
||||
}
|
||||
return renderTag(context, key, data[childKey], config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
function renderTag(context, key, data, config = {}, groupConfig) {
|
||||
@@ -526,6 +527,7 @@ var VueMeta = (function (exports, vue) {
|
||||
.map((child) => {
|
||||
return renderTag(context, key, child, config, groupConfig);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
const { tag = config.tag || key } = data;
|
||||
@@ -542,7 +544,7 @@ var VueMeta = (function (exports, vue) {
|
||||
if (isArray(data)) {
|
||||
return data.map(({ vnode }) => vnode);
|
||||
}
|
||||
return data.vnode;
|
||||
return data && data.vnode;
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -591,8 +593,9 @@ var VueMeta = (function (exports, vue) {
|
||||
content = getSlotContent(context, slotName, content, data);
|
||||
}
|
||||
else {
|
||||
const { nameless, keyAttribute } = config;
|
||||
const { nameless } = config;
|
||||
if (!nameless) {
|
||||
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
|
||||
if (keyAttribute) {
|
||||
attributes[keyAttribute] = fullName;
|
||||
}
|
||||
@@ -604,6 +607,10 @@ var VueMeta = (function (exports, vue) {
|
||||
const finalTag = groupConfig && groupConfig.tagNamespace
|
||||
? `${groupConfig.tagNamespace}:${tag}`
|
||||
: tag;
|
||||
if (finalTag === 'title' && !context.isSSR) {
|
||||
document.title = content;
|
||||
return;
|
||||
}
|
||||
// console.info('FINAL TAG', finalTag)
|
||||
// console.log(' ATTRIBUTES', attributes)
|
||||
// console.log(' CONTENT', content)
|
||||
@@ -763,7 +770,6 @@ var VueMeta = (function (exports, vue) {
|
||||
const Metainfo = MetainfoImpl;
|
||||
|
||||
const ssrAttribute = 'data-vm-ssr';
|
||||
const active = vue.reactive({});
|
||||
function addVnode(isSSR, teleports, to, vnodes) {
|
||||
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
|
||||
if (!isSSR) {
|
||||
@@ -803,7 +809,7 @@ var VueMeta = (function (exports, vue) {
|
||||
install(app) {
|
||||
app.component('Metainfo', Metainfo);
|
||||
app.config.globalProperties.$metaManager = this;
|
||||
app.provide(metaActiveKey, active);
|
||||
app.provide(metaActiveKey, this.target.context.active);
|
||||
}
|
||||
addMeta(metadata, vm) {
|
||||
if (!vm) {
|
||||
@@ -862,20 +868,27 @@ var VueMeta = (function (exports, vue) {
|
||||
}
|
||||
}
|
||||
render({ slots } = {}) {
|
||||
const active = this.target.context.active;
|
||||
// TODO: clean this method
|
||||
const { isSSR } = this;
|
||||
// cleanup ssr tags if not yet done
|
||||
if (!isSSR && !this.ssrCleanedUp) {
|
||||
this.ssrCleanedUp = true;
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const cleanUpSSR = () => {
|
||||
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
|
||||
if (ssrTags && ssrTags.length) {
|
||||
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
|
||||
}
|
||||
}, { once: true });
|
||||
};
|
||||
if (document.readyState === 'loading') {
|
||||
// Listen for DOM loaded because tags in the body couldnt
|
||||
// have loaded yet once the manager does it first render
|
||||
// (preferable there should only be one meta render on hydration)
|
||||
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
|
||||
}
|
||||
else {
|
||||
cleanUpSSR();
|
||||
}
|
||||
}
|
||||
const teleports = {};
|
||||
for (const key in active) {
|
||||
@@ -924,6 +937,7 @@ var VueMeta = (function (exports, vue) {
|
||||
}
|
||||
return resolver.resolve(options, contexts, active, key, pathSegments);
|
||||
};
|
||||
const active = vue.reactive({});
|
||||
const mergedObject = createMergedObject(resolve, active);
|
||||
// TODO: validate resolver
|
||||
const manager = new MetaManager(isSSR, config, mergedObject, resolver);
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-meta",
|
||||
"version": "3.0.0-alpha.6",
|
||||
"version": "3.0.0-alpha.7",
|
||||
"description": "Manage HTML metadata in Vue.js components with SSR support",
|
||||
"main": "dist/vue-meta.cjs.js",
|
||||
"browser": "dist/vue-meta.esm-browser.min.js",
|
||||
|
||||
Reference in New Issue
Block a user