Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin additionalPages frontmatter attribute ignored when combined with content #1157

Closed
sullivanpt opened this issue Jan 3, 2019 · 2 comments
Labels
type: bug Something isn't working

Comments

@sullivanpt
Copy link

  • [x ] I confirm that this is a issue rather than a question.

Bug report

Version

[email protected]

Steps to reproduce

make a vuepress plugin like the following

module.exports = {
  name: 'my-plugin',
  async additionalPages () {
    return [
      {
        path: '/mypath/',
        frontmatter: {
           key: 'value'
        },
        content: '## my custom\npage {{ $page }}'
      }
    ]
  }
}

build vuepress (e.g. "npm run docs:build"), open the generated file (e.g. /dist/mypath/index.html), observe the frontmatter is empty.

page {
            "title": "my custom",
            "frontmatter": {  },
            "regularPath": "/changelog/",

What is expected?

frontmatter in additionalPages should be included in $page

What is actually happening?

$page.frontmatter is empty. I'm just guessing that it is being overridden by the "empty" frontmatter embedded in the content attribute; if so then I think these should be merged (up for debate I guess).

Note, not a blocker as one can work around this by defining the frontmatter in a plugin extendPageData. But it seems awkward. The following works as expected:

  async additionalPages () {
    return [
      {
        path: '/mypath/',
        content: '## my custom\npage {{ $page }}'
      }
    ],
  extendPageData ($page) {
    $page.frontmatter.key = 'value'
  }

Other relevant information

  • Your OS: Windows
  • Node.js version: 8.12.0
  • Browser version: N/A
  • Is this a global or local install? local
  • Which package manager did you use for the install? npm 6.4.1
@ulivz ulivz added the type: bug Something isn't working label Jan 8, 2019
@ulivz ulivz closed this as completed in 6d68bee Jan 8, 2019
ulivz added a commit that referenced this issue Jan 8, 2019
@sullivanpt
Copy link
Author

Awesome, thank you! Is it OK if I follow in your footsteps and submit some similar PR, such as not overwriting 'title' if explicitly provided?

@ulivz
Copy link
Member

ulivz commented Jan 8, 2019

@sullivanpt Welcome to submit PRs 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants