8000 fix: improve frontmatter handling · NamesMT/unplugin-vue-markdown@2f1f281 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f1f281

Browse files
committed
fix: improve frontmatter handling
1 parent e931338 commit 2f1f281

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/head.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,29 @@ export function preprocessHead<T extends Frontmatter>(frontmatter: T, options: R
2424
if (head.title) {
2525
if (!meta.find((i: any) => i.property === 'og:title'))
2626
meta.push({ property: 'og:title', content: head.title })
27+
28+
if (!meta.find((i: any) => i.name === 'twitter:title'))
29+
meta.push({ name: 'twitter:title', content: head.title })
2730
}
2831

2932
if (head.description) {
33+
if (!meta.find((i: any) => i.name === 'description'))
34+
meta.push({ name: 'description', content: head.description })
35+
3036
if (!meta.find((i: any) => i.property === 'og:description'))
3137
meta.push({ property: 'og:description', content: head.description })
3238

33-
if (!meta.find((i: any) => i.name === 'description'))
34-
meta.push({ name: 'description', content: head.description })
39+
if (!meta.find((i: any) => i.name === 'twitter:description'))
40+
meta.push({ name: 'twitter:description', content: head.description })
3541
}
3642

3743
if (head.image) {
3844
if (!meta.find((i: any) => i.property === 'og:image'))
3945
meta.push({ property: 'og:image', content: head.image })
4046

47+
if (!meta.find((i: any) => i.name === 'twitter:image'))
48+
meta.push({ name: 'twitter:image', content: head.image })
49+
4150
if (!meta.find((i: any) => i.property === 'twitter:card'))
4251
meta.push({ name: 'twitter:card', content: 'summary_large_image' })
4352
}

0 commit comments

Comments
 (0)
0