pages-themes / architect

Architect is a Jekyll theme for GitHub Pages
https://pages-themes.github.io/architect/
Creative Commons Zero v1.0 Universal
313 stars 799 forks source link

Feature request: "on this page" mini TOC #12

Closed noamtamim closed 6 years ago

noamtamim commented 7 years ago

As seen on Leap Day.

I prefer this theme visually, but the on-this-page TOC is a nice touch.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jmini commented 5 years ago

In the "Leap Day" theme, this is solved with javascript (based on jquery). Relevant parts:

An empty list is added in the layout file:

https://github.com/pages-themes/leap-day/blob/af5c3638f65f80f9baca1ece30017cf55f91cf1e/_layouts/default.html#L40-L42

And a script loads the TOC and add the list items:

https://github.com/pages-themes/leap-day/blob/af5c3638f65f80f9baca1ece30017cf55f91cf1e/assets/js/main.js#L16-L28

This script is registered in layout:

https://github.com/pages-themes/leap-day/blob/af5c3638f65f80f9baca1ece30017cf55f91cf1e/_layouts/default.html#L9-L10


See also this https://github.com/pages-themes/cayman/issues/16#issuecomment-326620674 where {:toc} is mentioned.

jmini commented 5 years ago

I did not managed to use the {:toc} inside the default.html layout file, even with the inputs from https://github.com/jekyll/jekyll/issues/5843


At the end I have switched to jekyll-toc, a solution built on top of the liquid templating engine.

This works well on GitHub pages.