Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Add optional table of contents for blog posts #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danyspin97
Copy link
Contributor

No description provided.

@mtn
Copy link
Owner

mtn commented Sep 17, 2018

screen shot 2018-09-16 at 9 49 51 pm

Is this what it's supposed to look like?

I think the concept is useful, but there should be some styling before this is merged. Any thoughts?

Thanks for your work in initiating this! 🎈

@mtn
Copy link
Owner

mtn commented Sep 17, 2018

I also think this might be a better as a post-level parameter.

@danyspin97
Copy link
Contributor Author

screenshot_2018-09-17_13-27-04

Strange, it should look like this. I'll investigate this.

@danyspin97
Copy link
Contributor Author

danyspin97 commented Sep 17, 2018

It should be fixed now.
Let me explain better how it works now. It gets all the line that are formatted as h[1-4] and put them in the same level in the table of contents, that is enabled by adding toc: true in the post parameters and it is disabled by default.

The original snippet tried to understand the level number and insert relative nested lists. The wanted result was something like this:

  • Header (h1)
    • Subheader (h2)
    • Subheader (h2)
      • Subsubheader (h3)

If you prefer to have the table of contents formatted as this last example, I don't mind working to achieve this last example, but I would prefer to have it simple as it is currently.

@mtn
Copy link
Owner

mtn commented Sep 18, 2018

Hm, it seems kind of strange to flatten the table of contents, at least without offering both as an option. By default, I'd think it'd be better to retain information about the structure of the post.

But I don't want to make this too much of a burden either. We could merge this, and allow it to be enabled with a flag like flat-toc and then possibly add a hierarchical toc in the future.

@danyspin97
Copy link
Contributor Author

danyspin97 commented Sep 23, 2018

Improved! Now the table of contents respect the paragraph level, as the original post. I needed to add some css to remove blank lines between the levels. It also reads all the section from h2 to h4. I've a left the button "Table of Contents" as the original gist.

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

Successfully merging this pull request may close these issues.

2 participants