Skip to content

Commit 8d6e870

Browse files
committed
fix: Change union rule to array type meta #2614
1 parent 844b56a commit 8d6e870

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Diff for: packages/@vuepress/core/lib/client/root-mixins/updateMeta.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import unionBy from 'lodash/unionBy'
22

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+
318
export default {
419
// created will be called on both client and ssr
520
created () {
@@ -86,7 +101,11 @@ function updateMetaTags (newMetaTags, currentMetaTags) {
86101
*/
87102
function metaIdentifier (tag) {
88103
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+
}
90109
}
91110
return JSON.stringify(tag)
92111
}

0 commit comments

Comments
 (0)