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 TOC to documents #85

Open
ChristophLabacher opened this issue Aug 13, 2019 · 2 comments · Fixed by #135
Open

Add TOC to documents #85

ChristophLabacher opened this issue Aug 13, 2019 · 2 comments · Fixed by #135
Assignees

Comments

@ChristophLabacher
Copy link
Member

Our markdown parser has an option to create a Table of Contents based on the headings of a document. We should enable this option and add toc as a key to the API response for documents.

@ChristophLabacher
Copy link
Member Author

Since we want to offer a TOC for both HTML and MD docs we have to parse it ourselves – the blackfriday parser offers a TOC function, but it only adds a html TOC on the top of the document.

My favorite solution was for us to parse the MD to HTML (or take the HTML that is already there) and then write our own solution to parse an object from the heading elements in the code.

I think the doc object of our API response should also include a toc object:

{
  title: …,
  raw: …,
  html: …,
  components: …,
  toc: [
    {
      title: "Colors",
      children: [
        { title: "Primary" },
        { title: "Secondary" }
      ]
    },
    {
      title: "Typography"
    }
  ]
}

@ChristophLabacher
Copy link
Member Author

Keeping this open, since documentation needs to be added to the website.

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

Successfully merging a pull request may close this issue.

2 participants