File tree 1 file changed +20
-1
lines changed
packages/@vuepress/core/lib/client/root-mixins
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 1
1
import unionBy from 'lodash/unionBy'
2
2
3
+ // @see https://ogp.me/
4
+ const META_TYPE_ARRAY = [
5
+ 'article:author' ,
6
+ 'article:tag' ,
7
+ 'book:author' ,
8
+ 'book:tag' ,
9
+ 'music:album' ,
10
+ 'music:musician' ,
11
+ 'og:locale:alternate' ,
12
+ 'video:actor' ,
13
+ 'video:director' ,
14
+ 'video:tag' ,
15
+ 'video:writer'
16
+ ]
17
+
3
18
export default {
4
19
// created will be called on both client and ssr
5
20
created ( ) {
@@ -86,7 +101,11 @@ function updateMetaTags (newMetaTags, currentMetaTags) {
86
101
*/
87
102
function metaIdentifier ( tag ) {
88
103
for ( const item of [ 'name' , 'property' , 'itemprop' ] ) {
89
- if ( tag . hasOwnProperty ( item ) ) return tag [ item ] + item
104
+ if ( tag . hasOwnProperty ( item ) ) {
105
+ const key = tag [ item ]
106
+ const isTypeArray = tag . hasOwnProperty ( 'content' ) && ~ META_TYPE_ARRAY . indexOf ( key )
107
+ return key + item + ( isTypeArray ? tag . content : '' )
108
+ }
90
109
}
91
110
return JSON . stringify ( tag )
92
111
}
You can’t perform that action at this time.
0 commit comments