mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-17 05:20:34 +03:00
fix: use document.title to update title on the client
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<!doctype html>
|
||||
<html {{ htmlAttrs }}>
|
||||
<head {{ headAttrs }}>
|
||||
<title>Hello</title>
|
||||
{{ head }}
|
||||
<link rel="stylesheet" href="/global.css">
|
||||
</head>
|
||||
|
||||
+11
-3
@@ -12,7 +12,8 @@ import type {
|
||||
MetaRendered,
|
||||
MetaTagConfigKey,
|
||||
SlotScopeProperties,
|
||||
TODO
|
||||
TODO,
|
||||
ExcludesFalsy
|
||||
} from './types'
|
||||
|
||||
const cachedElements: {
|
||||
@@ -77,6 +78,7 @@ export function renderGroup (
|
||||
|
||||
return renderTag(context, key, data[childKey], config as MetaConfigSectionTag, groupConfig)
|
||||
})
|
||||
.filter(Boolean as any as ExcludesFalsy)
|
||||
.flat()
|
||||
}
|
||||
|
||||
@@ -86,7 +88,7 @@ export function renderTag (
|
||||
data: TODO,
|
||||
config: MetaConfigSectionTag = {},
|
||||
groupConfig?: MetaGroupConfig
|
||||
): MetaRendered | MetaRenderedNode {
|
||||
): MetaRendered | MetaRenderedNode | void {
|
||||
// console.info('renderTag', key, data, config, groupConfig)
|
||||
|
||||
const contentAttributes = ['content', 'json', 'rawContent']
|
||||
@@ -97,6 +99,7 @@ export function renderTag (
|
||||
.map((child) => {
|
||||
return renderTag(context, key, child, config, groupConfig)
|
||||
})
|
||||
.filter(Boolean as any as ExcludesFalsy)
|
||||
.flat()
|
||||
}
|
||||
|
||||
@@ -118,7 +121,7 @@ export function renderTag (
|
||||
return data.map(({ vnode }) => vnode)
|
||||
}
|
||||
|
||||
return data.vnode
|
||||
return data && data.vnode
|
||||
})
|
||||
} else {
|
||||
let i = 0
|
||||
@@ -194,6 +197,11 @@ export function renderTag (
|
||||
? `${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)
|
||||
|
||||
@@ -6,6 +6,9 @@ export * from './config'
|
||||
|
||||
export type Modify<T, R> = Omit<T, keyof R> & R;
|
||||
|
||||
export type Truthy<T> = T extends undefined | void | null | false | 0 | '' ? never : T
|
||||
export type ExcludesFalsy = <T>(x: T) => x is Truthy<T>
|
||||
|
||||
export type TODO = any
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user