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

Add Ability to specify how deep page headers should go #984

Closed
bretterer opened this issue Nov 6, 2018 · 7 comments
Closed

Add Ability to specify how deep page headers should go #984

bretterer opened this issue Nov 6, 2018 · 7 comments
Labels
has PR Has a related PR type: feature request Request to add a new feature

Comments

@bretterer
Copy link
Contributor

Feature request

It would be nice to have the ability to specify how deep the extractHeaders method goes.
Currently, it has a hard coded value of ['h2', 'h3']
Our current markdown files use h4 as well in order to handle some table of contents for the page in sidebar form.

What problem does this feature solve?

When doing a table of contents in the sidebar, this feature would allow you to specify how deep the TOC should go based on headers.

What does the proposed API look like?

config.js

module.exports = {
    themeConfig: {
        parseHeaders: ['h2','h3','h4']
    }
}

How should this be implemented in your opinion?

The above would be a themeConfig option and will replace the default hard coded value located at
https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/prepare/Page.js#L92

Are you willing to work on this yourself?**

Yes

@Leedehai
Copy link

Leedehai commented Nov 7, 2018

This is a much needed feature.
Additionally, I wish the sidebar is able to handle "skipped" headings, i.e. a h3-level heading directly under h1 without h2 in between, and a h4-level heading directly under h2 without h3 in between. Like so:

h1
|-- h3 (this)
|-- h2
|   |-- h4 (and this)
|   |-- h3
|   |    |-- h4
|   |    `-- h4
|   `-- h3
`-- h2
    |-- h3
    `-- h3

@ulivz ulivz added the type: feature request Request to add a new feature label Nov 7, 2018
@bretterer
Copy link
Contributor Author

Looking into how to code this, Once issue is it seems that currently, the Page.js does not have access to the config file. I have been looking for samples of the prepare files requiring the config file and and falling short. It may require some re-structure/re-work of how that is set

@0w0k
Copy link

0w0k commented Nov 8, 2018

Welcome to pull requests, This is a much needed feature.

@Leedehai
Copy link

Leedehai commented Nov 9, 2018

Heck, even Vuepress's own README contains skipped headings: an h2 heading ("Status") is not governed by any h1 heading. The first h1 heading in the article ("Vuepress") is below it. :)

@bretterer
Copy link
Contributor Author

Picking this up this week. Targeting to have a PR by the end of week

@yiwiz-sai
Copy link

this is obviously necessary.

@bretterer
Copy link
Contributor Author

@pianoboysai I believe this was merged in through another PR #1945 after being told to "avoid wasting your time" and let the "feature be implemented by official collaborators"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has PR Has a related PR type: feature request Request to add a new feature
Projects
None yet
5 participants