Wide, index-like TOC #62
-
How could a table of contents like the following mockup be automatically created? The left side really isn't required, just the right side. Being expanded like this provides the user a quick view of all it's contents. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sure, this is entirely possible. If you have all of those articles in an array, let's say, {% for post in posts %}
{% assign postUrl = post.url | relative_url %}
{% include toc.html html=post.content base_url=postUrl %}
{% endfor %} ^ that snippet is untested, but that's the idea of how you'd go about generating a site-wide TOC. |
Beta Was this translation helpful? Give feedback.
Sure, this is entirely possible. If you have all of those articles in an array, let's say,
posts
, you would be able to loop through all of them and just feed each post's content intotoc.html
. Then use thebase_url
parameter to point to another page (the HTML ID will automatically be appended).^ that snippet is untested, but that's the idea of how you'd go about generating a site-wide TOC.