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

Define Headers to Parse during Page Prep - resolve #984 #1004

Closed
wants to merge 15 commits into from
Closed

Define Headers to Parse during Page Prep - resolve #984 #1004

wants to merge 15 commits into from

Conversation

bretterer
Copy link
Contributor

Summary
This PR resolves #984

Currently the header parsing is hard coded to ['h2', 'h3']. This code changes that to give the ability to configure this in the themeOptions config.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated
  • Related tests have been updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

Copy link
Member

@ulivz ulivz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update packages/@vuepress/markdown-loader/index.js.

@vuejs vuejs deleted a comment from 0w0k Nov 15, 2018
@bretterer
Copy link
Contributor Author

bretterer commented Nov 15, 2018

@ulivz Updated. Thanks!

Copy link
Member

@ulivz ulivz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work. there is only an issue.

You support the feature in the core, but put the configuration under themeConfig, which is unreasonable. Only these options handled by the theme should be placed under themeConfig.

Put this option under siteConfig.markdown would be better.

@bretterer
Copy link
Contributor Author

No worries. That makes sense. I will update this tonight/tomorrow and get some updates to you

@bretterer
Copy link
Contributor Author

Sorry, Holidays got in the way... Update coming

@bretterer
Copy link
Contributor Author

@ulivz updated.

I had to gain access to the config, and I think this is the best way to do it. Maybe all of this should be extracted out to a getConfig module that can be reused?

@bretterer
Copy link
Contributor Author

@ulivz wondered if you had a chance to take a look at this. We are getting closer to needing this feature in our development.

@bretterer
Copy link
Contributor Author

Would it be possible to get this into 1.0.0-alpha.28 release?

let config = loadConfig(path.resolve(sourceDir, '.vuepress'), false)
if (isFunction(config)) {
config = config(this)
}
Copy link
Member

@ulivz ulivz Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't re-load user's config at the scope of makrdown-loader, while this loader should only focus on how to transpile the source markdown file to Vue component.

extractHeaders should be a option for this loader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill do some more digging, but I couldn't find any way to get to the extractHeaders option from within this file already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying it should be available already inside of the loader file if defined in the .vuepress/config.js file such as:

module.exports = ctx => ({
  markdown: {
    extractHeaders: ['h2','h3','h4','h5']
  }
})

if that is the case, I have looked at the this object and could not find it anywhere.

@ulivz ulivz force-pushed the master branch 2 times, most recently from 04f50a4 to edcf194 Compare December 13, 2018 18:21
@bretterer
Copy link
Contributor Author

@ulivz This last rebase caused a bunch of issues in this PR changed files list. I have updated to include siteConfig in the options for the markdown-loader

I can make a new PR, based on the changes here that is a bit cleaner, bit it seems it won't let me clean up this PR for some reason.

Any chance we can get this into the next release (hopefully before the new year)?

@bretterer
Copy link
Contributor Author

@ulivz this PR can be either merged or can be replaced by #1111 due to rebase issues

@ulivz
Copy link
Member

ulivz commented Mar 13, 2019

To avoid wasting your time, I recommend that this feature be implemented by official collaborators.

@ulivz ulivz closed this Mar 13, 2019
@bretterer
Copy link
Contributor Author

@ulivz: And, how would one (Okta and Myself) become an official collaborator for VuePress on an open source tool? I am pretty sure this was not wasting my time as I was trying to donate my time to help expand this project.

@vojkny
Copy link

vojkny commented May 25, 2022

So is this is abandoned and not implemented?

@bretterer
Copy link
Contributor Author

@knyttl this was handled through #1945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Ability to specify how deep page headers should go
3 participants