mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 01:50:34 +03:00
fix: SSR active, dont use global active var due to runInNewContext: false (#668)
Meta is not reflected in the second page rendering. Co-authored-by: hosoi-appland <hosoi@appland.co.jp> Co-authored-by: Pim <pimlie@hotmail.com>
This commit is contained in:
+3
-3
@@ -23,8 +23,6 @@ import type {
|
|||||||
|
|
||||||
export const ssrAttribute = 'data-vm-ssr'
|
export const ssrAttribute = 'data-vm-ssr'
|
||||||
|
|
||||||
export const active: MetaActive = reactive({})
|
|
||||||
|
|
||||||
export function addVnode (isSSR: boolean, teleports: MetaTeleports, to: string, vnodes: VNode | Array<VNode>): void {
|
export function addVnode (isSSR: boolean, teleports: MetaTeleports, to: string, vnodes: VNode | Array<VNode>): void {
|
||||||
const nodes = (isArray(vnodes) ? vnodes : [vnodes]) as Array<VNode>
|
const nodes = (isArray(vnodes) ? vnodes : [vnodes]) as Array<VNode>
|
||||||
|
|
||||||
@@ -84,6 +82,7 @@ export class MetaManager {
|
|||||||
return resolver.resolve(options, contexts, active, key, pathSegments)
|
return resolver.resolve(options, contexts, active, key, pathSegments)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const active: MetaActive = reactive({})
|
||||||
const mergedObject = createMergedObject<MetaSource>(resolve, active)
|
const mergedObject = createMergedObject<MetaSource>(resolve, active)
|
||||||
|
|
||||||
// TODO: validate resolver
|
// TODO: validate resolver
|
||||||
@@ -95,7 +94,7 @@ export class MetaManager {
|
|||||||
app.component('Metainfo', Metainfo)
|
app.component('Metainfo', Metainfo)
|
||||||
|
|
||||||
app.config.globalProperties.$metaManager = this
|
app.config.globalProperties.$metaManager = this
|
||||||
app.provide(metaActiveKey, active)
|
app.provide(metaActiveKey, this.target.context.active)
|
||||||
}
|
}
|
||||||
|
|
||||||
addMeta (metadata: MetaSource, vm?: ComponentInternalInstance): MetaProxy {
|
addMeta (metadata: MetaSource, vm?: ComponentInternalInstance): MetaProxy {
|
||||||
@@ -170,6 +169,7 @@ export class MetaManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render ({ slots }: { slots?: Slots } = {}): VNode[] {
|
render ({ slots }: { slots?: Slots } = {}): VNode[] {
|
||||||
|
const active = this.target.context.active;
|
||||||
// TODO: clean this method
|
// TODO: clean this method
|
||||||
const { isSSR } = this
|
const { isSSR } = this
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user