From 7c4962e39af0de5a47f0dbd0cb1f8d31b0486e99 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 12 May 2020 22:40:49 +0800 Subject: [PATCH] fix(compatibility): compatibility for version 0.1.X (#351) --- layouts/_default/baseof.html | 6 ++++++ layouts/partials/assets.html | 9 +++++++-- layouts/partials/comment.html | 30 ++++++++++++++++-------------- layouts/posts/single.html | 13 ++++++++++--- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 4bcabfd..cf923ba 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -17,11 +17,17 @@ {{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}} {{- .Scratch.Set "analytics" .Site.Params.analytics -}} {{- .Scratch.Set "comment" $params.comment -}} + {{- if eq .Params.comment true -}} + {{- .Scratch.Set "comment" .Site.Params.comment -}} + {{- else if eq .Params.comment false -}} + {{- .Scratch.Set "comment" dict -}} + {{- end -}} {{- else if eq .Site .Sites.First -}} {{- warnf "\n\nCurrent environment is \"development\". The \"comment system\", \"CDN\" and \"fingerprint\" will be disabled.\n当前运行环境是 \"development\". \"评论系统\", \"CDN\" 和 \"fingerprint\" 不会启用.\n" -}} {{- end -}} {{- .Scratch.Set "params" $params -}} + {{- $this := dict "desktop" .Site.Params.header.desktopMode "mobile" .Site.Params.header.mobileMode | dict "headerMode" | dict "config" -}} {{- .Scratch.Set "this" $this -}} diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index edb52c8..236c851 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -89,8 +89,13 @@ {{- end -}} {{- /* KaTeX */ -}} -{{- if $params.math.enable -}} - {{- $math := $params.math -}} +{{- $math := $params.math -}} +{{- if eq $math true -}} + {{- $math = .Site.Params.page.math | default dict -}} +{{- else if eq $math false -}} + {{- $math = dict "enable" false -}} +{{- end -}} +{{- if $math.enable -}} {{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.katexJS | default "lib/katex/katex.min.js" -}} diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 71ea677..1f18b30 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -1,14 +1,15 @@ {{- $cdn := .Scratch.Get "cdn" | default dict -}} {{- $fingerprint := .Scratch.Get "fingerprint" -}} -{{- $comment := .Scratch.Get "comment" | default (dict "disqus" dict "gitalk" dict "valine" dict "facebook" dict "telegram" dict "commento" dict "utterances" dict) -}} +{{- $comment := .Scratch.Get "comment" | default dict -}} {{- $commentConfig := dict -}} {{- if $comment.enable -}}
{{- /* Disqus Comment System */ -}} - {{- if $comment.disqus.enable -}} + {{- $disqus := $comment.disqus | default dict -}} + {{- if $disqus.enable -}}
- {{- $source := printf "https://%s.disqus.com/embed.js" $comment.disqus.shortname -}} + {{- $source := printf "https://%s.disqus.com/embed.js" $disqus.shortname -}} {{- dict "source" $source "defer" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}