Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
fix(compatibility): compatibility for version 0.1.X (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored May 12, 2020
1 parent 7d0603e commit 7c4962e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
6 changes: 6 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

Expand Down
9 changes: 7 additions & 2 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" -}}
Expand Down
30 changes: 16 additions & 14 deletions layouts/partials/comment.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{{- $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 -}}
<div id="comments">
{{- /* Disqus Comment System */ -}}
{{- if $comment.disqus.enable -}}
{{- $disqus := $comment.disqus | default dict -}}
{{- if $disqus.enable -}}
<div id="disqus_thread" class="comment"></div>
{{- $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" -}}
<noscript>
Please enable JavaScript to view the comments powered by <a href="https://disqus.com/?ref_noscript">Disqus</a>.
</noscript>
{{- end -}}

{{- /* Gitalk Comment System */ -}}
{{- if $comment.gitalk.enable -}}
{{- $gitalk := $comment.gitalk -}}
{{- $gitalk := $comment.gitalk | default dict -}}
{{- if $gitalk.enable -}}
<div id="gitalk" class="comment"></div>
{{- $source := $cdn.gitalkCSS | default "lib/gitalk/gitalk.css" -}}
{{- dict "source" $source "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
Expand All @@ -30,8 +31,8 @@
{{- end -}}

{{- /* Valine Comment System */ -}}
{{- if $comment.valine.enable -}}
{{- $valine := $comment.valine -}}
{{- $valine := $comment.valine | default dict -}}
{{- if $valine.enable -}}
<div id="valine" class="comment"></div>
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}}
{{- dict "source" "lib/valine/valine.scss" "toCSS" $options | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
Expand All @@ -57,8 +58,8 @@
{{- end -}}

{{- /* Facebook Comment System */ -}}
{{- if $comment.facebook.enable -}}
{{- $facebook := $comment.facebook -}}
{{- $facebook := $comment.facebook | default dict -}}
{{- if $facebook.enable -}}
<div id="fb-root" class="comment"></div>
<div
class="fb-comments"
Expand All @@ -74,8 +75,8 @@
{{- end -}}

{{- /* Telegram Comments System */ -}}
{{- if $comment.telegram.enable -}}
{{- $telegram := $comment.telegram -}}
{{- $telegram := $comment.telegram | default dict -}}
{{- if $telegram.enable -}}
<div id="telegram-comments" class="comment"></div>
{{- $attr := printf `data-comments-app-website="%s"` $telegram.siteID -}}
{{- $attr = printf `%s data-limit="%s"` $attr ($telegram.limit | default 5) -}}
Expand All @@ -101,7 +102,8 @@
{{- end -}}

{{- /* Commento Comment System */ -}}
{{- if $comment.commento.enable -}}
{{- $commento := $comment.commento | default dict -}}
{{- if $commento.enable -}}
<div id="commento"></div>
{{- dict "source" "https://cdn.commento.io/js/commento.js" "defer" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
<noscript>
Expand All @@ -110,9 +112,9 @@
{{- end -}}

{{- /* Utterances Comment System */ -}}
{{- if $comment.utterances.enable -}}
{{- $utterances := $comment.utterances | default dict -}}
{{- if $utterances.enable -}}
<div id="utterances"></div>
{{- $utterances := $comment.utterances -}}
{{- $commentConfig = dict "repo" $utterances.repo | dict "utterances" | merge $commentConfig -}}
{{- $commentConfig = $utterances.issueTerm | default "pathname" | dict "issueTerm" | dict "utterances" | merge $commentConfig -}}
{{- $commentConfig = dict "label" $utterances.label | dict "utterances" | merge $commentConfig -}}
Expand Down
13 changes: 10 additions & 3 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
{{- define "content" -}}
{{- $params := .Scratch.Get "params" -}}

{{- $toc := $params.toc -}}
{{- if eq $toc true -}}
{{- $toc = .Site.Params.page.toc | default dict -}}
{{- else if eq $toc false -}}
{{- $toc = dict "enable" false -}}
{{- end -}}

{{- /* Auto TOC */ -}}
{{- if ne $params.toc.enable false -}}
{{- if ne $toc.enable false -}}
<div class="toc" id="toc-auto">
<h2 class="toc-title">{{ T "contents" }}</h2>
<div class="toc-content{{ if eq $params.toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
</div>
{{- end -}}

Expand Down Expand Up @@ -66,7 +73,7 @@ <h2 class="single-subtitle">{{ . }}</h2>
{{- end -}}

{{- /* Static TOC */ -}}
{{- if ne $params.toc.enable false -}}
{{- if ne $toc.enable false -}}
<div class="details toc" id="toc-static">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
Expand Down

0 comments on commit 7c4962e

Please sign in to comment.