From c8089db11f24b5759436c8bbd521649ca6ae6ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Tue, 28 Jun 2022 17:21:34 +0800 Subject: [PATCH 1/8] :bug: Fix code highlight style in list, fixed #3. --- assets/css/_common/scaffolding/highlight/index.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/_common/scaffolding/highlight/index.scss b/assets/css/_common/scaffolding/highlight/index.scss index b4c686e..68c6fcc 100644 --- a/assets/css/_common/scaffolding/highlight/index.scss +++ b/assets/css/_common/scaffolding/highlight/index.scss @@ -10,7 +10,7 @@ pre { margin: 0; } -p > code { +p > code, li > code { @extend %code-inline; border-radius: 3px; padding: 3px 6px; From 748c44e25d0ef5d6ec4aeeb957baade132f46845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Wed, 29 Jun 2022 08:08:19 +0800 Subject: [PATCH 2/8] :bug: Fixed the back top button in sidebar margin pixes. --- assets/css/_schemes/Pisces/_sidebar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/_schemes/Pisces/_sidebar.scss b/assets/css/_schemes/Pisces/_sidebar.scss index 4d6e9b1..d3ec63c 100644 --- a/assets/css/_schemes/Pisces/_sidebar.scss +++ b/assets/css/_schemes/Pisces/_sidebar.scss @@ -83,7 +83,7 @@ // Only when back2top.sidebar is true, apply the following styles .back-to-top { background: var(--body-bg-color); - margin: 8px - $sidebar-offset -10px -18px; + margin: 8px -#{$sidebar-offset} -10px -18px; &.back-to-top-on { margin-top: 16px; From b9cd603c04d3b3bb84a61acc8be23c894804445d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Wed, 29 Jun 2022 08:56:13 +0800 Subject: [PATCH 3/8] :construction: Change the code block style settings. --- .../scaffolding/highlight/copy-code.scss | 68 ++++++++++--------- assets/css/main.scss | 7 +- assets/js/config.js | 2 +- assets/js/next-boot.js | 2 +- assets/js/utils.js | 2 +- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/assets/css/_common/scaffolding/highlight/copy-code.scss b/assets/css/_common/scaffolding/highlight/copy-code.scss index 369854f..63d538c 100644 --- a/assets/css/_common/scaffolding/highlight/copy-code.scss +++ b/assets/css/_common/scaffolding/highlight/copy-code.scss @@ -1,6 +1,3 @@ -.highlight:hover .copy-btn, pre:hover .copy-btn { - opacity: 1; -} .highlight { @@ -15,38 +12,45 @@ } } -.copy-btn { - color: $black-dim; - cursor: pointer; - line-height: 1.6; - opacity: 0; - padding: 2px 6px; - position: absolute; - right: 8px; - top: 4px; - transition: opacity $transition-ease; - background: var(--highlight-background); +@if $codeblock_copy_btn_enable { - @if $codeblock_copy_btn_style == 'flat' { - background: white; - border: 0; - font-size: $font-size-smaller; - - } @else if $codeblock_copy_btn_style == 'mac' { - color: var(--highlight-foreground); - font-size: 14px; - border-radius: 3px; - } @else { - background-color: $gainsboro; - background-image: linear-gradient(#fcfcfc, $gainsboro); - border: 1px solid #d5d5d5; - border-radius: 3px; - font-size: $font-size-smaller; - + .highlight:hover .copy-btn, pre:hover .copy-btn { + opacity: 1; + } + + .copy-btn { + color: $black-dim; + cursor: pointer; + line-height: 1.6; + opacity: 0; + padding: 2px 6px; + position: absolute; + right: 8px; + top: 4px; + transition: opacity $transition-ease; + background: var(--highlight-background); + + @if $codeblock_style == 'flat' { + background: white; + border: 0; + font-size: $font-size-smaller; + + } @else if $codeblock_style == 'mac' { + color: var(--highlight-foreground); + font-size: 14px; + border-radius: 3px; + } @else { + background-color: $gainsboro; + background-image: linear-gradient(#fcfcfc, $gainsboro); + border: 1px solid #d5d5d5; + border-radius: 3px; + font-size: $font-size-smaller; + + } } } -@if $codeblock_copy_btn_style == 'mac' { +@if $codeblock_style == 'mac' { .highlight { border-radius: 5px; box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .4); @@ -65,4 +69,4 @@ @include round-icon(12px); } } -} +} \ No newline at end of file diff --git a/assets/css/main.scss b/assets/css/main.scss index 5f4f2d2..cb1031d 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -52,7 +52,8 @@ $highlight_dark_foreground : #fff; $highlight_light_background : #565656; $highlight_light_foreground : #fff; -$codeblock_copy_btn_style : {{ $P.codeblock.copyBtn.style }}; +$codeblock_copy_btn_enable : {{ $P.codeblock.copyBtn }}; +$codeblock_style : {{ $P.codeblock.style }}; // Sidebar $sidebar_offset : {{ $P.sidebar.offset }}; @@ -113,7 +114,9 @@ $reading_progress_reversed : {{ $P.readingProgress.reversed }}; // Thirdparty $math_mathjax_enable : {{ $P.math.mathjax.enable }}; -$related_posts_enable : {{ $P.relatedPosts.enable }}; +// TODO +//$related_posts_enable : {{ $P.relatedPosts.enable }}; +$related_posts_enable : false; $pdf_enable : {{ $P.pdf.enable }}; $pdf_height : {{ $P.pdf.height }}; diff --git a/assets/js/config.js b/assets/js/config.js index 992939b..e67c69c 100644 --- a/assets/js/config.js +++ b/assets/js/config.js @@ -10,7 +10,7 @@ if (!window.NexT) window.NexT = {}; "darkmode" : {{ .Site.Params.darkmode }}, "version" : "{{ .Site.Data.config.version }}", "sidebar" : {{ .Site.Params.sidebar | jsonify }}, - "copycode" : {{ .Site.Params.codeblock.copyBtn | jsonify }}, + "copybtn" : {{ .Site.Params.codeblock.copyBtn }}, "bookmark" : {{ .Site.Params.bookmark | jsonify }}, "comments" : {{ .Site.Params.comments | jsonify }}, "mediumzoom" : {{ .Site.Params.mediumzoom }}, diff --git a/assets/js/next-boot.js b/assets/js/next-boot.js index a37e40e..66bb821 100644 --- a/assets/js/next-boot.js +++ b/assets/js/next-boot.js @@ -45,7 +45,7 @@ NexT.boot.refresh = function() { CONFIG.pangu && window.pangu.spacingPage(); CONFIG.isPage && NexT.utils.replacePostCRLink(); - CONFIG.isPage && NexT.utils.registerCopyCode(); + CONFIG.isPage && CONFIG.copybtn && NexT.utils.registerCopyCode(); NexT.utils.registerTabsTag(); /*NexT.utils.registerActiveMenuItem(); NexT.utils.registerLangSelect();*/ diff --git a/assets/js/utils.js b/assets/js/utils.js index 0a80fc2..3baa4de 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -41,7 +41,7 @@ NexT.utils = { */ registerCopyCode: function() { let figure = document.querySelectorAll('.highlight pre'); - if (figure.length === 0 || !CONFIG.copycode) return; + if (figure.length === 0 || !CONFIG.copybtn) return; figure.forEach(element => { let cn = element.querySelector('code').className; // TODO seems hard code need find other ways fixed it. From dafea2e479d99ec1c0fe970974de2acb24739694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Wed, 29 Jun 2022 19:31:16 +0800 Subject: [PATCH 4/8] :construction: optimization comment system setting. --- assets/css/main.scss | 12 +++++++----- .../partials/_thirdparty/comment/artalk.html | 2 -- .../partials/_thirdparty/comment/giscus.html | 18 ++++++++++++++++++ .../_thirdparty/comment/utterances.html | 2 -- .../partials/_thirdparty/comment/waline.html | 4 +--- 5 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 layouts/partials/_thirdparty/comment/giscus.html diff --git a/assets/css/main.scss b/assets/css/main.scss index cb1031d..718a92c 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -125,14 +125,16 @@ $algolia_search_enable : {{ $P.algoliaSearch.enable }}; $local_search_enable : {{ $P.localSearch.enable }}; // Online IM -$gitalk_enable : {{ $P.gitalk.enable }}; +//$gitalk_enable : {{ $P.gitalk.enable }}; +$gitalk_enable : false; $gitter_enable : {{ $P.gitter.enable }}; // Comment -$disqusjs_enable : {{ $P.disqusjs.enable }}; -$livere_enable : {{ $P.livere.enable }}; -$utterances_enable : {{ $P.utterances.enable }}; -$waline_enable : {{ $P.waline.enable }}; +//$disqusjs_enable : {{ $P.disqusjs.enable }}; +$disqusjs_enable : false; +$livere_enable : {{ isset $P.livere "uid" }}; +$utterances_enable : {{ isset $P.utterances "utterances" }}; +$waline_enable : {{ isset $P.waline "serverurl" }}; {{- with .Site.Params.comments }} {{- $tce := and (isset . "nav") (and .storage (gt (len .nav) 1)) }} $two_comments_enable : {{ $tce }}; diff --git a/layouts/partials/_thirdparty/comment/artalk.html b/layouts/partials/_thirdparty/comment/artalk.html index 7787d7e..f0683a3 100644 --- a/layouts/partials/_thirdparty/comment/artalk.html +++ b/layouts/partials/_thirdparty/comment/artalk.html @@ -1,4 +1,3 @@ -{{- if .Site.Params.artalk.enable }} {{- with .Site.Params.artalk }} @@ -18,5 +17,4 @@ }) {{- end }} -{{- end }} diff --git a/layouts/partials/_thirdparty/comment/giscus.html b/layouts/partials/_thirdparty/comment/giscus.html new file mode 100644 index 0000000..d1b476f --- /dev/null +++ b/layouts/partials/_thirdparty/comment/giscus.html @@ -0,0 +1,18 @@ +{{- with .Site.Params.giscus }} +
+ +{{- end }} \ No newline at end of file diff --git a/layouts/partials/_thirdparty/comment/utterances.html b/layouts/partials/_thirdparty/comment/utterances.html index 6115b95..2d26357 100644 --- a/layouts/partials/_thirdparty/comment/utterances.html +++ b/layouts/partials/_thirdparty/comment/utterances.html @@ -1,5 +1,4 @@ {{- with .Site.Params.utterances }} -{{- if .enable }} {{- end }} -{{- end }} diff --git a/layouts/partials/_thirdparty/comment/waline.html b/layouts/partials/_thirdparty/comment/waline.html index ff07bb6..a533da5 100644 --- a/layouts/partials/_thirdparty/comment/waline.html +++ b/layouts/partials/_thirdparty/comment/waline.html @@ -1,4 +1,3 @@ -{{- if .Site.Params.waline.enable }} {{- with .Site.Params.waline }}
@@ -21,5 +20,4 @@ dark : "auto" }); -{{- end }} -{{- end }} \ No newline at end of file +{{- end }} \ No newline at end of file From ec5d8419e1a175030e0ef3d912a8d60b7d4c50c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Thu, 30 Jun 2022 08:04:32 +0800 Subject: [PATCH 5/8] :construction: optimization other settings. --- assets/js/config.js | 1 - exampleSite/start.sh | 5 +++-- layouts/_default/_markup/render-link.html | 4 ++-- layouts/partials/_thirdparty/comment/giscus.html | 1 + layouts/partials/footer.html | 10 ++++++---- layouts/partials/post/footer_meta/reward.html | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/assets/js/config.js b/assets/js/config.js index e67c69c..cde3ea8 100644 --- a/assets/js/config.js +++ b/assets/js/config.js @@ -13,7 +13,6 @@ if (!window.NexT) window.NexT = {}; "copybtn" : {{ .Site.Params.codeblock.copyBtn }}, "bookmark" : {{ .Site.Params.bookmark | jsonify }}, "comments" : {{ .Site.Params.comments | jsonify }}, - "mediumzoom" : {{ .Site.Params.mediumzoom }}, "lazyload" : {{ .Site.Params.lazyload }}, "pangu" : {{ .Site.Params.pangu }}, "stickytabs" : {{ .Site.Params.tabs.sticky }}, diff --git a/exampleSite/start.sh b/exampleSite/start.sh index 806fa5f..c917278 100644 --- a/exampleSite/start.sh +++ b/exampleSite/start.sh @@ -1,5 +1,6 @@ #!/bin/bash -# +# 本地快速启动脚本 +# Quick start in local. next() { cat << EOT @@ -12,7 +13,7 @@ next() { ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ ╚═╝ ======================================== NexT version $1 -Documentation: https://hugo-next.js.org +Documentation: https://hugo-next.eu.org ======================================== EOT } diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 8b66301..e4603f8 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,5 +1,5 @@ -{{- $extURL := .Page.Site.Params.exturl.enable }} - +{{- $extURL := and .Page.Site.Params.exturl.enable (strings.HasPrefix .Destination "http") }} + {{ .Text | safeHTML }} {{- if and $extURL .Page.Site.Params.exturl.icon }} diff --git a/layouts/partials/_thirdparty/comment/giscus.html b/layouts/partials/_thirdparty/comment/giscus.html index d1b476f..706ef23 100644 --- a/layouts/partials/_thirdparty/comment/giscus.html +++ b/layouts/partials/_thirdparty/comment/giscus.html @@ -1,4 +1,5 @@ {{- with .Site.Params.giscus }} +{{ printf "%t" (isset . "repo") }}
+ -{{- end }} \ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e980003..a545428 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -3,6 +3,6 @@ {{- partial "head/twitter.html" . }} {{- partial "head/googleplus.html" . }} {{- partial "head/facebook.html" . }} -{{ partial "head/verify.html" . }} -{{- partial "head/style.html" . }} -{{- partial "head/analytics.html" . }} \ No newline at end of file +{{- partial "head/verify.html" . }} +{{- partialCached "head/style.html" . }} +{{- partialCached "head/analytics.html" . }} \ No newline at end of file diff --git a/layouts/partials/head/analytics.html b/layouts/partials/head/analytics.html index 3e798ed..0105e07 100644 --- a/layouts/partials/head/analytics.html +++ b/layouts/partials/head/analytics.html @@ -1 +1,5 @@ -{{- partial "_thirdparty/analytics/51la.html" . }} \ No newline at end of file +{{- with .Site.Params.analytics }} +{{- if isset . "laid" }} + {{ partial "_thirdparty/analytics/51la.html" .laId }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index e74b0a0..338c015 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1,3 +1,16 @@ + + +{{- if .Site.Params.darkmode }} + +{{- else }} + +{{- end }} +{{ hugo.Generator }} + + + + + {{- if .IsPage }} @@ -15,8 +28,3 @@ {{- .Scratch.Set "metaImg" $img }} -{{- if .Site.Params.darkmode }} - -{{- else }} - -{{- end }} diff --git a/layouts/partials/head/style.html b/layouts/partials/head/style.html index f2f8889..c43d385 100644 --- a/layouts/partials/head/style.html +++ b/layouts/partials/head/style.html @@ -21,6 +21,9 @@ {{- $scss := resources.Get "css/main.scss" }} {{- $scss = $scss | resources.ExecuteAsTemplate "main.scss" . }} {{- $css := $scss | toCSS (dict "targetPath" "/css/main.css" "outputStyle" "expanded") }} +{{- if hugo.IsProduction }} +{{- $css = $css | minify | fingerprint }} +{{- end }} {{- if .IsPage }}