Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@vuepress/core/lib/client/index.ssr.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<meta name="description" content="{{ description }}">
{{{ userHeadTags }}}
{{{ pageMeta }}}
{{{ pageLink }}}
{{{ renderResourceHints() }}}
{{{ renderStyles() }}}
</head>
Expand Down
18 changes: 11 additions & 7 deletions packages/@vuepress/core/lib/node/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ module.exports = class Build extends EventEmitter {

// #565 Avoid duplicate description meta at SSR.
const meta = (page.frontmatter && page.frontmatter.meta || []).filter(item => item.name !== 'description')
const pageMeta = renderPageMeta(meta)
const link = page.frontmatter && page.frontmatter.link || []
const pageLink = renderPageEmptyTag('link', link)
const pageMeta = renderPageEmptyTag('meta', meta)

const context = {
url: page.path,
userHeadTags: this.userHeadTags,
pageMeta,
pageLink,
title: 'VuePress',
lang: 'en',
description: ''
Expand Down Expand Up @@ -225,16 +228,17 @@ function renderAttrs (attrs = {}) {
}

/**
* Render meta tags
* Render html empty tags
*
* @param {Array} meta
* @param {String} tagName
* @param {Array} tags
* @returns {Array<string>}
*/

function renderPageMeta (meta) {
if (!meta) return ''
return meta.map(m => {
let res = `<meta`
function renderPageEmptyTag (tagName, tags) {
if (!tags) return ''
return tags.map(m => {
let res = `<tag`
Object.keys(m).forEach(key => {
res += ` ${key}="${escape(m[key])}"`
})
Expand Down
15 changes: 15 additions & 0 deletions packages/docs/docs/guide/frontmatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ meta:
---
```

### link

- Type: `array`
- Default: `undefined`

Specify extra link tags to be injected:

``` yaml
---
link:
- rel: canonical
content: https://my-canonical-url.com/article/1
---
```

## Predefined Variables Powered By Default Theme

### navbar
Expand Down