@@ -37,8 +37,26 @@ export default {
37
37
const pageMeta = this . $page . frontmatter . meta || [ ]
38
38
// pageMetaTags have higher priority than siteMetaTags
39
39
// description needs special attention as it has too many entries
40
- return unionBy ( [ { name : 'description' , content : this . $description } ] ,
41
- pageMeta , this . siteMeta , metaIdentifier )
40
+ const templateMeta = [ ]
41
+ if ( typeof document !== 'undefined' ) {
42
+ const templateMetaTags = document . querySelectorAll ( 'meta' )
43
+ templateMetaTags . forEach ( tag => {
44
+ const names = tag . getAttributeNames ( )
45
+ if ( names . length === 1 ) {
46
+ const attr = tag . getAttributeNames ( ) [ 0 ]
47
+ const obj = { }
48
+ obj [ attr ] = tag . getAttribute ( attr )
49
+ templateMeta . push ( obj )
50
+ } else if ( names . every ( e => [ 'name' , 'content' ] . includes ( e ) ) ) {
51
+ templateMeta . push ( { name : tag . name , content : tag . content } )
52
+ } else if ( names . every ( e => [ 'http-equiv' , 'content' ] . includes ( e ) ) ) {
53
+ templateMeta . push ( { 'http-equiv' : tag . httpEquiv , content : tag . content } )
54
+ }
55
+ } )
56
+ }
57
+ // pageMetaTags have higher priority than siteMetaTags
58
+ // description needs special attention as it has too many entries
59
+ return unionBy ( [ { name : 'description' , content : this . $description } ] , pageMeta , this . siteMeta , templateMeta , metaIdentifier )
42
60
}
43
61
} ,
44
62
0 commit comments