File tree 2 files changed +24
-0
lines changed
packages/@vuepress/core/lib
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 7
7
< meta name ="description " content ="{{ description }} ">
8
8
< meta name ="generator " content ="VuePress {{ version }} ">
9
9
{{{ userHeadTags }}}
10
+ {{{ pageMeta }}}
10
11
{{{ renderResourceHints() }}}
11
12
{{{ renderStyles() }}}
12
13
</ head >
Original file line number Diff line number Diff line change @@ -138,9 +138,14 @@ module.exports = class Build extends EventEmitter {
138
138
readline . cursorTo ( process . stdout , 0 )
139
139
process . stdout . write ( `Rendering page: ${ pagePath } ` )
140
140
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
+
141
145
const context = {
142
146
url : page . path ,
143
147
userHeadTags : this . userHeadTags ,
148
+ pageMeta,
144
149
title : 'VuePress' ,
145
150
lang : 'en' ,
146
151
description : '' ,
@@ -220,6 +225,24 @@ function renderAttrs (attrs = {}) {
220
225
}
221
226
}
222
227
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
+
223
246
/**
224
247
* find and remove empty style chunk caused by
225
248
* https://github.com/webpack-contrib/mini-css-extract-plugin/issues/85
You can’t perform that action at this time.
0 commit comments