revises tocbot configuration and documentation

This commit is contained in:
Huy Tran 2018-09-30 11:58:57 +10:00
parent b517159c0e
commit e785ac36f1
3 changed files with 21 additions and 1 deletions

View file

@ -5,8 +5,9 @@ __2018-09__
* Add _Table of Contents_
* Configure using `.Site.Params.toc` with two possible value: "hugo" (using Hugo `{{ .TableOfContents }}`, and "tocbot" (using [Tocbot](https://tscanlin.github.io/tocbot/)), remove `.Site.Params.toc` to disable TOC
* Change [_layouts/partials/header/styles.html_](https://github.com/htr3n/hyde-hyde/blob/master/layouts/partials/header/styles.html) to check `.Site.Params.toc` and add the corresponding styles
* Change [_layouts/partials/page-single/content.html_](_layouts/partials/page-single/content.html_ ) to add TOC per `.Site.Params.toc`
* Change [_layouts/partials/page-single/content.html_](https://github.com/htr3n/hyde-hyde/blob/master/layouts/partials/page-single/content.html ) to add TOC per `.Site.Params.toc`
* Add styles [_static-src/scss/hugo-toc.scss_](https://github.com/htr3n/hyde-hyde/blob/master/static-src/scss/hugo-toc.scss) and [_static-src/scss/tocbot.scss_](https://github.com/htr3n/hyde-hyde/blob/master/static-src/scss/tocbot.scss) that generate `hugo-toc.css` and `tocbot.css`, respectively
* Tocbot can be configured in [_layouts/partials/page-single/footer.html_](_layouts/partials/page-single/footer.html_) with options as described in [its documentation](https://tscanlin.github.io/tocbot/#api)
__2018-07__

View file

@ -13,6 +13,7 @@ Since version 2.0, __`hyde-hyde`__ has been overhauled and, therefore, might cau
* Experimenting a collapsible menu in mobile mode
* Adding _Table of Contents_
* Configure using `.Site.Params.toc` with two possible value: "hugo" (using Hugo `{{ .TableOfContents }}`, and "tocbot" (using [Tocbot](https://tscanlin.github.io/tocbot/)), remove `.Site.Params.toc` to disable TOC
* Tocbot can be configured in [_layouts/partials/page-single/footer.html_](_layouts/partials/page-single/footer.html_) with options as described in [its documentation](https://tscanlin.github.io/tocbot/#api)
For more details, please refer to [CHANGELOG](https://github.com/htr3n/hyde-hyde/blob/master/CHANGELOG.md). A real site in action can be found [here](https://htr3n.github.io) and its [WIP source](https://github.com/htr3n/htr3n-blog) for reference.

View file

@ -4,3 +4,21 @@
{{ end }}
{{ partial "footer/font-awesome-js.html" . }}
{{ partial "highlight-js.html" . }}
{{ with .Site.Params.toc }}
{{ if eq . "tocbot" }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.1.1/tocbot.js"></script>
<script type="text/javascript">
if (tocbot) {
tocbot.init({
// Where to render the table of contents.
tocSelector: '.toc',
// Where to grab the headings to build the table of contents.
contentSelector: '.post',
// Which headings to grab inside of the contentSelector element.
headingSelector: 'h2, h3, h4',
collapseDepth: 4
});
}
</script>
{{ end }}
{{ end }}