athul / archie

A minimal Hugo Theme
https://athul.github.io/archie
MIT License
941 stars 292 forks source link

Add support to TOC #70

Open ilongshan opened 1 year ago

ilongshan commented 1 year ago

Hope it can add support to TOC, like hugo-theme-even:

https://hugo-theme-even.netlify.app/post/even-preview/

image
athul commented 1 year ago

Hi,

Hugo can automatically do this -> https://gohugo.io/content-management/toc/

You can send a PR for the same :)

ilongshan commented 1 year ago

Thanks for the info. I am not a very familar with css, and cannot make TOC floating on the right side of the article. Hope someone else can implement this feature.

hcartiaux commented 2 weeks ago

I've forked so I cannot do a PR quickly, but I've added these lines (14-18) to support TOC in posts: https://github.com/hcartiaux/hugo-theme-archie-solarized/blob/1115b97906be0ea5fd4daf8690e2fe41c901a135/layouts/_default/single.html#L14

Plus CSS here: https://github.com/hcartiaux/hugo-theme-archie-solarized/blob/1115b97906be0ea5fd4daf8690e2fe41c901a135/assets/css/main.css#L181

And then you can add toc: true to your post headers to enable it: https://github.com/hcartiaux/hugo-theme-archie-solarized/blob/1115b97906be0ea5fd4daf8690e2fe41c901a135/exampleSite/content/posts/tg-gh.md?plain=1#L6