Skip to content

Commit

Permalink
fix: duplicate description meta (close: #565)
Browse files Browse the repository at this point in the history
- When user set description via front-matter's meta, description generated will be duplicate which
is not friendly to SEO.
  • Loading branch information
ulivz committed Jun 10, 2018
1 parent 7cd7c64 commit de35315
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/app/dataMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export default function dataMixin (siteData) {
: selfTitle || 'VuePress'
},
$description () {
// #565 hoist description from meta
if (this.$page.frontmatter.meta) {
const descriptionMeta = this.$page.frontmatter.meta.filter(item => item.name === 'description')[0]
if (descriptionMeta) return descriptionMeta.content
}
return this.$page.frontmatter.description || this.$localeConfig.description || this.$site.description || ''
},
$lang () {
Expand Down
5 changes: 4 additions & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
readline.cursorTo(process.stdout, 0)
process.stdout.write(`Rendering page: ${pagePath}`)

const pageMeta = renderPageMeta(page.frontmatter && page.frontmatter.meta)
// #565 avoid duplicate description
const meta = (page.frontmatter && page.frontmatter.meta || []).filter(item => item.name !== 'description')
const pageMeta = renderPageMeta(meta)

const context = {
url: pagePath,
userHeadTags,
Expand Down

0 comments on commit de35315

Please sign in to comment.