refactors layouts for head, footer and post

This commit is contained in:
Huy Tran 2018-07-27 08:41:33 +10:00
parent e8e4ba4c3b
commit e980cbedc8
21 changed files with 93 additions and 61 deletions

View file

@ -0,0 +1,7 @@
{{- if ne .Params.showcomments false -}}
{{ if .Site.DisqusShortname -}}
{{- partial "page-single/commenting/disqus.html" . -}}
{{- else if .Site.Params.GraphCommentId -}}
{{- partial "page-single/commenting/graphcomment.html" . -}}
{{- end -}}
{{- end }}

View file

@ -0,0 +1,29 @@
<div id="disqus_thread"></div>
<script type="text/javascript">
/*
Check and don't inject Disqus on localhost/127.0.0.1, however, it does not
work for customised local domains, e.g. example.test, example.dev
*/
(function () {
if (location.hostname === "localhost" ||
location.hostname === "127.0.0.1" ||
location.hostname === "") {
return;
}
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
var disqus_shortname = '{{ .Site.DisqusShortname }}';
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>
Please enable JavaScript to view the
<a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a>
</noscript>
<a href="http://disqus.com/" class="dsq-brlink">comments powered by
<span class="logo-disqus">Disqus</span>
</a>

View file

@ -0,0 +1,10 @@
<div id="graphcomment"></div>
<script type="text/javascript">
window.graphcomment_id = '{{ .Site.Params.GraphCommentId }}';
/* - - - DON'T EDIT BELOW THIS LINE - - - */
(function() {
var gc = document.createElement('script'); gc.type = 'text/javascript'; gc.async = true;
gc.src = 'https://graphcomment.com/js/integration.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(gc);
})();
</script>

View file

@ -0,0 +1,16 @@
<article>
<header>
<h1>{{ .Title }}</h1>
{{ with .Params.subtitle }}
<span class="post__subtitle">
{{.}}
</span>
{{ end }}
{{ partial "page-single/post-meta-top.html" . }}
</header>
<div class="post">
{{ .Content }}
</div>
{{ partial "page-single/post-meta-bottom.html" . }}
{{ partial "page-single/post-related.html" . }}
</article>

View file

@ -0,0 +1,14 @@
<div class="post--navigation post--navigation-single">
{{ with .PrevInSection -}}
<a href="{{ .RelPermalink }}" class="post--navigation-prev">
<i aria-hidden="true" class="fa fa-chevron-left"></i>
<span>{{ .Title }}</span>
</a>
{{- end }}
{{ with .NextInSection -}}
<a href="{{ .RelPermalink }}" class="post--navigation-next">
<span>{{ .Title }}</span>
<i aria-hidden="true" class="fa fa-chevron-right"></i>
</a>
{{- end }}
</div>

View file

@ -0,0 +1,34 @@
{{ if ne .Params.showpagemeta false }}
<div class="post__meta">
<!-- published date -->
{{ if not .Date.IsZero -}}
<i class="fas fa-calendar-alt"></i> {{ .Date.Format (.Site.Params.dateformat | default "Jan 02, 2006") -}}
{{- end }}
<!-- categories -->
{{- with .Params.categories -}}
{{- $total := len . -}}
{{ if gt $total 0 -}}
in
{{- $total := sub $total 1 -}}
{{- range $i, $cat := sort . }}
<a class="post__category" href="{{ "/categories/" | relURL }}{{ $cat | urlize }}">{{ $cat | upper }}</a>
{{ if lt $i $total }}•{{ end }}
{{- end -}}
{{- end -}}
{{- end -}}
<!-- tags -->
{{ with .Params.tags }}
{{ $total := len . }}
{{ if gt $total 0 }}
<br/>
{{ $subtotal := sub $total 1 }} <i class="fas fa-tags"></i>
{{ range $i, $tag := . }}
<a class="post__tag" href="{{ "/tags/" | relURL }}{{ $tag | urlize }}">{{ $tag | lower }}</a>
{{ if lt $i $subtotal }} {{ end }}
{{ end }}
{{ end }}
{{ end }}
<br/>
<i class="fas fa-clock"></i> {{ .ReadingTime }} min read
</div>
{{ end }}

View file

@ -0,0 +1,10 @@
{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related -}}
<div class="post__related">
<!-- related content -->
<h2>Related Articles</h2>
<ul class="related-posts">
{{ partial "posts-list.html" . }}
</ul>
</div>
{{- end }}

View file

@ -0,0 +1,2 @@
{{ .Page.Scratch.Delete "fig" }}
{{ .Page.Scratch.Delete "table" }}

View file

@ -0,0 +1,2 @@
{{ .Page.Scratch.Set "fig" 1 }}
{{ .Page.Scratch.Set "table" 1 }}