Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zhaohuabing/hugo-theme-cleanwhite.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhaohuabing <zhaohuabing@gmail.com>2021-09-29 15:32:09 +0300
committerzhaohuabing <zhaohuabing@gmail.com>2021-09-29 15:32:16 +0300
commit74061e447ee0d05445a6a8f4a0202dd18e1b6087 (patch)
tree81ab68d430f25c1af8072eccc9b1c16718466a66 /layouts
parentbf03717ea1a54be95d55c559a098017964285375 (diff)
support catalog sidebar
https://github.com/zhaohuabing/hugo-theme-cleanwhite/issues/108 Signed-off-by: zhaohuabing <zhaohuabing@gmail.com>
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/single.html22
-rw-r--r--layouts/partials/footer.html63
2 files changed, 83 insertions, 2 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index e25ed99..e1ca443 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -65,16 +65,18 @@
<!-- Post Container -->
<div class="
- col-lg-11 col-lg-offset-1
+ col-lg-8 col-lg-offset-2
col-md-10 col-md-offset-1
post-container">
+ <!--
{{ if not (eq (.Param "showtoc") false) }}
<header>
<h2>TOC</h2>
</header>
{{.TableOfContents}}
{{ end }}
+ -->
{{ .Content }}
{{ if .Site.Params.reward }}
@@ -96,10 +98,26 @@
</li>
{{ end }}
</ul>
-
{{ partial "comments.html" . }}
+ </div>
+ <!-- Side Catalog Container -->
+ {{ if not (eq (.Param "showtoc") false) }}
+ <div class="
+ col-lg-2 col-lg-offset-0
+ visible-lg-block
+ sidebar-container
+ catalog-container">
+ <div class="side-catalog">
+ <hr class="hidden-sm hidden-xs">
+ <h5>
+ <a class="catalog-toggle" href="#">CATALOG</a>
+ </h5>
+ <ul class="catalog-body"></ul>
+ </div>
</div>
+ {{ end }}
+
<!-- Sidebar Container -->
<div class="
col-lg-11 col-lg-offset-1
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 4a0cfb8..537e7fe 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -306,3 +306,66 @@
{{ if .Site.GoogleAnalytics }}
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}
+
+
+<!-- Side Catalog -->
+{{ if not (eq (.Param "showtoc") false) }}
+<script type="text/javascript">
+ function generateCatalog(selector) {
+
+ // interop with multilangual
+ //if ('page.multilingual' == 'true') {
+ // _containerSelector = 'div.post-container.active'
+ //} else {
+ _containerSelector = 'div.post-container'
+ //}
+
+ // init
+ var P = $(_containerSelector), a, n, t, l, i, c;
+ a = P.find('h1,h2,h3,h4,h5,h6');
+
+ // clean
+ $(selector).html('')
+
+ // appending
+ a.each(function () {
+ n = $(this).prop('tagName').toLowerCase();
+ i = "#" + $(this).prop('id');
+ t = $(this).text();
+ c = $('<a href="' + i + '" rel="nofollow">' + t + '</a>');
+ l = $('<li class="' + n + '_nav"></li>').append(c);
+ $(selector).append(l);
+ });
+ return true;
+ }
+
+ generateCatalog(".catalog-body");
+
+ // toggle side catalog
+ $(".catalog-toggle").click((function (e) {
+ e.preventDefault();
+ $('.side-catalog').toggleClass("fold")
+ }))
+
+ /*
+ * Doc: https://github.com/davist11/jQuery-One-Page-Nav
+ * Fork by Hux to support padding
+ */
+
+ loadAsync("{{ "js/jquery.nav.js" | relURL }}", function () {
+ $('.catalog-body').onePageNav({
+ currentClass: "active",
+ changeHash: !1,
+ easing: "swing",
+ filter: "",
+ scrollSpeed: 700,
+ scrollOffset: 0,
+ scrollThreshold: .2,
+ begin: null,
+ end: null,
+ scrollChange: null,
+ padding: 80
+ });
+ });
+</script>
+{{ end }}