|
|
@ -28,6 +28,8 @@ export function useUpdateHead(route: Route, siteDataByRouteRef: Ref<SiteData>) {
|
|
|
|
const pageData = route.data
|
|
|
|
const pageData = route.data
|
|
|
|
const siteData = siteDataByRouteRef.value
|
|
|
|
const siteData = siteDataByRouteRef.value
|
|
|
|
const pageTitle = pageData && pageData.title
|
|
|
|
const pageTitle = pageData && pageData.title
|
|
|
|
|
|
|
|
const pageDescription = pageData && pageData.description
|
|
|
|
|
|
|
|
const frontmatterHead = pageData && pageData.frontmatter.head
|
|
|
|
document.title = (pageTitle ? pageTitle + ` | ` : ``) + siteData.title
|
|
|
|
document.title = (pageTitle ? pageTitle + ` | ` : ``) + siteData.title
|
|
|
|
updateHeadTags([
|
|
|
|
updateHeadTags([
|
|
|
|
['meta', { charset: 'utf-8' }],
|
|
|
|
['meta', { charset: 'utf-8' }],
|
|
|
@ -42,11 +44,11 @@ export function useUpdateHead(route: Route, siteDataByRouteRef: Ref<SiteData>) {
|
|
|
|
'meta',
|
|
|
|
'meta',
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: 'description',
|
|
|
|
name: 'description',
|
|
|
|
content: siteData.description
|
|
|
|
content: pageDescription || siteData.description
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
|
|
|
...siteData.head,
|
|
|
|
...siteData.head,
|
|
|
|
...((pageData && pageData.frontmatter.head) || [])
|
|
|
|
...((frontmatterHead && filterOutHeadDescription(frontmatterHead)) || [])
|
|
|
|
])
|
|
|
|
])
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,3 +63,15 @@ function createHeadElement([tag, attrs, innerHTML]: HeadConfig) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return el
|
|
|
|
return el
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isMetaDescription(headConfig: HeadConfig) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
headConfig[0] === 'meta' &&
|
|
|
|
|
|
|
|
headConfig[1] &&
|
|
|
|
|
|
|
|
headConfig[1].name === 'description'
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function filterOutHeadDescription(head: HeadConfig[]) {
|
|
|
|
|
|
|
|
return head.filter((h) => !isMetaDescription(h))
|
|
|
|
|
|
|
|
}
|
|
|
|