From 50c6b667cd18fce831a9877649c4532782111e95 Mon Sep 17 00:00:00 2001 From: zzossig Date: Thu, 13 Feb 2020 11:31:30 +0900 Subject: toc level option added, menu highlight, some ui change --- assets/sass/layout/_navbar.scss | 2 +- assets/sass/pages/_single.scss | 7 ++++--- layouts/partials/head/scripts.html | 13 +++++++++++-- layouts/partials/main/sections/list-main.html | 3 +++ layouts/partials/main/sections/single-menu.html | 4 ++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/assets/sass/layout/_navbar.scss b/assets/sass/layout/_navbar.scss index 25c6843..4deb097 100644 --- a/assets/sass/layout/_navbar.scss +++ b/assets/sass/layout/_navbar.scss @@ -80,7 +80,7 @@ & > a { width: 100%; font-size: 18px; - padding: 0.5rem; + padding: 0.5rem 1rem; @include themify($themes) { color: themed('body-color'); diff --git a/assets/sass/pages/_single.scss b/assets/sass/pages/_single.scss index 3540a42..f340e65 100644 --- a/assets/sass/pages/_single.scss +++ b/assets/sass/pages/_single.scss @@ -23,8 +23,7 @@ font-family: $title-font; line-height: 3rem; overflow-wrap: break-word; - padding: 1rem; - margin: 1rem 0; + margin: 1.5rem 1rem 0.5rem; @include themify($themes) { color: themed("single-header-title-color"); @@ -34,6 +33,7 @@ &__meta { font-size: 0.8rem; margin-bottom: 1.5rem; + padding:0 1rem; @include flexbox(); @include align-items(center); @@ -393,7 +393,7 @@ pre:not(.chroma) { } .highlight > .chroma { - margin: 1em 0; + margin-bottom: 1.5rem; z-index: z('content'); overflow-x: auto; @@ -504,6 +504,7 @@ li .highlight > .chroma { } table:not(.lntable) { + margin: 0 1rem; td { code { padding: 2px 7px !important; diff --git a/layouts/partials/head/scripts.html b/layouts/partials/head/scripts.html index c63b17a..957a1a9 100644 --- a/layouts/partials/head/scripts.html +++ b/layouts/partials/head/scripts.html @@ -147,11 +147,20 @@ var tableOfContentsElem = tocElem ? tocElem.querySelector('#TableOfContents') : null; var singleContentsElem = document.querySelector('.single__contents'); + {{ $tocLevels := ($.Param "tocLevels") }} + var tocLevels = JSON.parse({{ $tocLevels | jsonify }}); + + if (tocLevels) { + tocLevels = tocLevels.toString(); + } else { + tocLevels = "h1, h2, h3, h4, h5, h6"; + } + window.onscroll = function () { var st = window.pageYOffset || document.documentElement.scrollTop; if (st > lastScrollTop) { // scroll down singleContentsElem ? - singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function(elem) { + singleContentsElem.querySelectorAll(tocLevels.toString()).forEach(function(elem) { if (document.documentElement.scrollTop >= elem.offsetTop) { if (tableOfContentsElem) { var id = elem.getAttribute('id'); @@ -165,7 +174,7 @@ }) : null; } else { // scroll up singleContentsElem ? - singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function(elem) { + singleContentsElem.querySelectorAll(tocLevels.toString()).forEach(function(elem) { if (document.documentElement.scrollTop >= elem.offsetTop) { if (tableOfContentsElem) { var id = elem.getAttribute('id'); diff --git a/layouts/partials/main/sections/list-main.html b/layouts/partials/main/sections/list-main.html index 90b3c9b..7e3e90b 100644 --- a/layouts/partials/main/sections/list-main.html +++ b/layouts/partials/main/sections/list-main.html @@ -1,5 +1,8 @@
{{ if eq .Type "blog" }} +
+ {{ .Title }} +
{{ partial "main/component/article-meta.html" . }}
diff --git a/layouts/partials/main/sections/single-menu.html b/layouts/partials/main/sections/single-menu.html index 32a706e..58ef6a0 100644 --- a/layouts/partials/main/sections/single-menu.html +++ b/layouts/partials/main/sections/single-menu.html @@ -30,8 +30,8 @@ {{ else }} {{ $lastUrlElement1 := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }} {{ $lastUrlElement2 := index (last 1 (split (delimit (split $currentURL "/") "," "") ",")) 0 }} -
  • - {{ .Title }} +
  • + {{ .Title }}
  • {{ end }} {{ end }} -- cgit v1.2.3