fix(theme): support missing meta description tag (#2639)

pull/2663/head
Mathieu POUSSE 1 year ago committed by GitHub
parent c2e79aa583
commit cfa870f060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,9 +37,15 @@ export function useUpdateHead(route: Route, siteDataByRouteRef: Ref<SiteData>) {
// update title and description // update title and description
document.title = createTitle(siteData, pageData) document.title = createTitle(siteData, pageData)
document const description = pageDescription || siteData.description
.querySelector(`meta[name=description]`)! let metaDescriptionElement = document.querySelector(
.setAttribute('content', pageDescription || siteData.description) `meta[name=description]`
)
if (metaDescriptionElement) {
metaDescriptionElement.setAttribute('content', description)
} else {
createHeadElement(['meta', { name: 'description', content: description }])
}
updateHeadTags( updateHeadTags(
mergeHead(siteData.head, filterOutHeadDescription(frontmatterHead)) mergeHead(siteData.head, filterOutHeadDescription(frontmatterHead))

Loading…
Cancel
Save