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
document.title = createTitle(siteData, pageData)
document
.querySelector(`meta[name=description]`)!
.setAttribute('content', pageDescription || siteData.description)
const description = pageDescription || siteData.description
let metaDescriptionElement = document.querySelector(
`meta[name=description]`
)
if (metaDescriptionElement) {
metaDescriptionElement.setAttribute('content', description)
} else {
createHeadElement(['meta', { name: 'description', content: description }])
}
updateHeadTags(
mergeHead(siteData.head, filterOutHeadDescription(frontmatterHead))

Loading…
Cancel
Save