Skip to content

Commit 4f50deb

Browse files
author
ludanxer
committed
Revert "fix: duplicate meta in ssr"
This reverts commit 5a02e2a.
1 parent 147d619 commit 4f50deb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Diff for: packages/@vuepress/core/lib/client/index.ssr.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="description" content="{{ description }}">
88
<meta name="generator" content="VuePress {{ version }}">
99
{{{ userHeadTags }}}
10+
{{{ pageMeta }}}
1011
{{{ renderResourceHints() }}}
1112
{{{ renderStyles() }}}
1213
</head>

Diff for: packages/@vuepress/core/lib/node/build/index.js

+23
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,14 @@ module.exports = class Build extends EventEmitter {
138138
readline.cursorTo(process.stdout, 0)
139139
process.stdout.write(`Rendering page: ${pagePath}`)
140140

141+
// #565 Avoid duplicate description meta at SSR.
142+
const meta = (page.frontmatter && page.frontmatter.meta || []).filter(item => item.name !== 'description')
143+
const pageMeta = renderPageMeta(meta)
144+
141145
const context = {
142146
url: page.path,
143147
userHeadTags: this.userHeadTags,
148+
pageMeta,
144149
title: 'VuePress',
145150
lang: 'en',
146151
description: '',
@@ -220,6 +225,24 @@ function renderAttrs (attrs = {}) {
220225
}
221226
}
222227

228+
/**
229+
* Render meta tags
230+
*
231+
* @param {Array} meta
232+
* @returns {Array<string>}
233+
*/
234+
235+
function renderPageMeta (meta) {
236+
if (!meta) return ''
237+
return meta.map(m => {
238+
let res = `<meta`
239+
Object.keys(m).forEach(key => {
240+
res += ` ${key}="${escape(m[key])}"`
241+
})
242+
return res + `>`
243+
}).join('')
244+
}
245+
223246
/**
224247
* find and remove empty style chunk caused by
225248
* https://github.com/webpack-contrib/mini-css-extract-plugin/issues/85

0 commit comments

Comments
 (0)