feat: add subtitle typeit

This commit is contained in:
Dillon ZENG
2019-08-08 06:05:51 +08:00
parent 0b85b03f62
commit 5e55b25c8a
4 changed files with 19 additions and 8 deletions

View File

@@ -16,10 +16,10 @@
</div> </div>
{{ end }} {{ end }}
{{ with .Site.Params.subtitle}} {{ with .Site.Params.subtitle }}
<h2 class="description"> <h2 class="description">
{{ . }} <div id="subtitle"></div>
</h2> </h2>
{{ end }} {{ end }}
</div> </div>

View File

@@ -12,8 +12,10 @@
<div class="avatar"><a href="/posts/"> <img src={{ $avatar }} alt="avatar"></a></div> <div class="avatar"><a href="/posts/"> <img src={{ $avatar }} alt="avatar"></a></div>
{{ end }} {{ end }}
{{ with .Site.Params.subtitle}} {{ with .Site.Params.subtitle }}
<h2 class="description">{{ . }}</h2> <h2 class="description">
<div id="subtitle"></div>
</h2>
{{ end }} {{ end }}
<div class="social-links"> <div class="social-links">

View File

@@ -36,11 +36,20 @@
{{ $countdown := ` {{ $countdown := `
<script src="https://cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js" integrity="sha256-Ikk5myJowmDQaYVCUD0Wr+vIDkN8hGI58SGWdE671A8=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js" integrity="sha256-Ikk5myJowmDQaYVCUD0Wr+vIDkN8hGI58SGWdE671A8=" crossorigin="anonymous"></script>
` }} ` }}
{{ $jquery | safeHTML }} {{ $jquery | safeHTML }}
{{ $typeit | safeHTML }}
{{ with .Site.Params.subtitle }}
<script>
if (!window.typeitMap) {
var typeitMap = {}
}
typeitMap["#subtitle"] = "{{ . }}";
</script>
{{ end }}
{{ if .IsPage }} {{ if .IsPage }}
{{ $prettify | safeHTML }} {{ $prettify | safeHTML }}
{{ $typeit | safeHTML }}
{{ $countdown | safeHTML }} {{ $countdown | safeHTML }}
{{ $scripts = $scripts | append $dynamicToTop }} {{ $scripts = $scripts | append $dynamicToTop }}

View File

@@ -7,7 +7,7 @@
{{ end }} {{ end }}
{{ $id = printf "#%s" $id }} {{ $id = printf "#%s" $id }}
<script> <script>
if (!typeitMap) { if (!window.typeitMap) {
var typeitMap = {} var typeitMap = {}
} }
typeitMap["{{ $id }}"] = {{ .Inner | safeHTML }}; typeitMap["{{ $id }}"] = {{ .Inner | safeHTML }};