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

Control level of header nodes processed in sidebar #16

Open
dkhunt27 opened this issue Mar 25, 2020 · 2 comments
Open

Control level of header nodes processed in sidebar #16

dkhunt27 opened this issue Mar 25, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@dkhunt27
Copy link

This is a feature request.

The sidebar is processing all my h2-h6 headings in my markdown as subtopics in the sidebar. Would be nice to be able to tell jamdocs that i only want to process h2-h3 or i dont want to process h6 or h5. This will give me more flexibility to control what gets added to the sidebar because some of our docs use a lot of headers.

Would be very cool if this can be a global and/or per document setting.

Thanks!

FYI, your template is great! thanks for all the work putting it together.

@samuelhorn
Copy link
Owner

Will see if I can solve this as well. Just need a bit of time 👍

@samuelhorn samuelhorn added the enhancement New feature or request label Apr 4, 2020
@samuelhorn samuelhorn self-assigned this Apr 4, 2020
@thefuntastic
Copy link

If it helps anybody else, this is the hardcoded approach I've taken so far:

In src/components/Sidebar.vue modify the graphQL to include header depth

<static-query>
query Menu {
  ...
  docs: allDoc {
    edges {
      node {
        slug
        headings {
          depth
          value
          anchor
        }
      }
    }
  }
}
</static-query>

Add the following to methods under export default (set your desired value accordingly):

methods: {
    ...
    filterHeadings(headings) {
      return headings.filter( h => {
        return h.depth < 3
      })
    },
    ...

And finally modify the template JSX to call this filter function

<li v-for="heading in filterHeadings(node.headings)" :key="heading.value">

I don't know enough yet about vue/gridsome how to make this a configurable toggle

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

No branches or pull requests

3 participants