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

Cannot access page headers that are not h2 or h3 #1903

Closed
1 task done
lesliecdubs opened this issue Oct 1, 2019 · 3 comments · Fixed by #1945 · May be fixed by adamlaska/osmos-cosmos-sdk#5
Closed
1 task done

Cannot access page headers that are not h2 or h3 #1903

lesliecdubs opened this issue Oct 1, 2019 · 3 comments · Fixed by #1945 · May be fixed by adamlaska/osmos-cosmos-sdk#5
Assignees
Labels
has PR Has a related PR type: feature request Request to add a new feature

Comments

@lesliecdubs
Copy link

  • I confirm that this is an issue rather than a question.

Bug report

Currently, header levels are hard-coded in VuePress core.

This limits our ability to access header levels beyond h3.

Our use case for this is a custom table of contents component that we are displaying on every page of our site. Our content uses h4s.

We don't want header levels below h3 to show up in our table of contents; however, we'd like for the preceding h3 to maintain the active indicator once a user has scrolled past an h4.

What is expected?

There should be some way to customize the header levels that are stored in this.$page.headers.

What is actually happening?

Header levels stored in this.$page.headers are hard-coded to only include h2 and h3.

cc @shortdiv

@kefranabg
Copy link
Collaborator

kefranabg commented Oct 2, 2019

Hi @lesliecdubs,

Thanks for the report.

If I correctly understand, the only thing you need is including h4 headers data in $page.headers so you can display these levels on your table of contents right?


const headers = extractHeaders(
   this._strippedContent,
   ['h2', 'h3', 'h4', 'h5', 'h6'],
   markdown
)

Would that solve your problem?

@shortdiv
Copy link
Contributor

shortdiv commented Oct 2, 2019

Jumping in here, since @lesliecdubs and I worked on this, yeah, that would solve the problem! The other option would be pulling in the desired headers from the vuepress config.

@kefranabg
Copy link
Collaborator

kefranabg commented Oct 9, 2019

See #1945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment