refactors layouts for head, footer and post
This commit is contained in:
parent
e8e4ba4c3b
commit
e980cbedc8
21 changed files with 93 additions and 61 deletions
|
@ -3,7 +3,7 @@
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ define "content" -}}
|
{{ define "content" -}}
|
||||||
{{ partial "page-list.html" . }}
|
{{ partial "page-list/content.html" . }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ define "footer" -}}
|
{{ define "footer" -}}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
{{ define "header" -}}
|
{{ define "header" -}}
|
||||||
{{ partial "page-variables-init.html" . }}
|
{{ partial "page-single/variables-init.html" . }}
|
||||||
{{ partial "header.html" . }}
|
{{ partial "header.html" . }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ define "content" -}}
|
{{ define "content" -}}
|
||||||
{{ partial "page-single.html" . }}
|
{{ partial "page-single/content.html" . }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ define "footer" -}}
|
{{ define "footer" -}}
|
||||||
<div class="container content">
|
<div class="container content">
|
||||||
{{- partial "highlight-js.html" . -}}
|
{{- partial "page-single/commenting.html" . -}}
|
||||||
{{- partial "commenting.html" . -}}
|
|
||||||
</div>
|
</div>
|
||||||
|
{{- partial "highlight-js.html" . -}}
|
||||||
{{ partial "footer.html" . }}
|
{{ partial "footer.html" . }}
|
||||||
{{ partial "page-variables-deinit.html" . }}
|
{{ partial "page-single/variables-deinit.html" . }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
<div id="disqus_thread"></div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
(function () {
|
|
||||||
// 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
|
|
||||||
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>
|
|
|
@ -1,5 +1,6 @@
|
||||||
{{ partial "footer/font-awesome-js.html" . }}
|
|
||||||
{{ if (.Site.GoogleAnalytics) -}}
|
{{ if (.Site.GoogleAnalytics) -}}
|
||||||
{{ "<!-- Google Analytics -->" | safeHTML }}
|
<!-- Google Analytics -->
|
||||||
{{ template "_internal/google_analytics_async.html" . }}
|
{{- template "_internal/google_analytics_async.html" . -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{ partial "footer/font-awesome-js.html" . }}
|
||||||
|
{{ partial "footer/deferred-styles.html" . }}
|
||||||
|
|
6
layouts/partials/footer/deferred-styles.html
Normal file
6
layouts/partials/footer/deferred-styles.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<noscript id="deferred-styles">
|
||||||
|
<!-- // styles to be deferred:
|
||||||
|
// https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}/css/styles.css" />
|
||||||
|
-->
|
||||||
|
</noscript>
|
|
@ -1 +1,4 @@
|
||||||
<script defer src="https://use.fontawesome.com/releases/v5.2.0/js/all.js" integrity="sha384-4oV5EgaV02iISL2ban6c/RmotsABqE4yZxZLcYMAdG7FAPsyHYAPpywE9PJo+Khy" crossorigin="anonymous"></script>
|
<script defer src="https://use.fontawesome.com/releases/v5.2.0/js/all.js"
|
||||||
|
integrity="sha384-4oV5EgaV02iISL2ban6c/RmotsABqE4yZxZLcYMAdG7FAPsyHYAPpywE9PJo+Khy"
|
||||||
|
crossorigin="anonymous">
|
||||||
|
</script>
|
||||||
|
|
18
layouts/partials/footer/load-deferred-styles.html
Normal file
18
layouts/partials/footer/load-deferred-styles.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<script>
|
||||||
|
var loadDeferredStyles = function () {
|
||||||
|
var addStylesNode = document.getElementById("deferred-styles");
|
||||||
|
if (addStylesNode) {
|
||||||
|
var replacement = document.createElement("div");
|
||||||
|
replacement.innerHTML = addStylesNode.textContent;
|
||||||
|
document.body.appendChild(replacement);
|
||||||
|
addStylesNode.parentElement.removeChild(addStylesNode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
|
||||||
|
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
|
||||||
|
if (raf) raf(function () {
|
||||||
|
window.setTimeout(loadDeferredStyles, 0);
|
||||||
|
});
|
||||||
|
else
|
||||||
|
window.addEventListener('load', loadDeferredStyles);
|
||||||
|
</script>
|
|
@ -1,9 +1,7 @@
|
||||||
<head>
|
<head>
|
||||||
<link href="http://gmpg.org/xfn/11" rel="profile">
|
<link href="http://gmpg.org/xfn/11" rel="profile">
|
||||||
{{ partial "header/meta.html" . }}
|
{{ partial "header/meta.html" . }}
|
||||||
{{ partial "header/highlight-css.html" . }}
|
{{ partial "header/styles.html" . }}
|
||||||
<link rel="stylesheet" href="{{ .Site.BaseURL }}/css/print.min.css" media="print">
|
|
||||||
<link rel="stylesheet" href="{{ .Site.BaseURL }}/css/hyde-hyde.css">
|
|
||||||
{{ `<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
{{ `<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{- if .Site.Params.highlightjs -}}
|
{{- if .Site.Params.highlightjs -}}
|
||||||
{{ "<!-- highlighting -->" | safeHTML }}
|
<!-- highlightjs -->
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/{{ .Site.Params.highlightjsstyle | default "default" }}.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/{{ .Site.Params.highlightjsstyle | default "default" }}.min.css">
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ if .Site.Params.PygmentsUseClasses -}}
|
{{ if .Site.Params.PygmentsUseClasses -}}
|
||||||
|
|
3
layouts/partials/header/styles.html
Normal file
3
layouts/partials/header/styles.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{{ partial "header/highlight-css.html" . }}
|
||||||
|
<link rel="stylesheet" href="{{ .Site.BaseURL }}/css/hyde-hyde.css">
|
||||||
|
<link rel="stylesheet" href="{{ .Site.BaseURL }}/css/print.min.css" media="print">
|
|
@ -1,7 +1,7 @@
|
||||||
{{- if ne .Params.showcomments false -}}
|
{{- if ne .Params.showcomments false -}}
|
||||||
{{ if .Site.DisqusShortname -}}
|
{{ if .Site.DisqusShortname -}}
|
||||||
{{- partial "commenting/disqus.html" . -}}
|
{{- partial "page-single/commenting/disqus.html" . -}}
|
||||||
{{- else if .Site.Params.GraphCommentId -}}
|
{{- else if .Site.Params.GraphCommentId -}}
|
||||||
{{- partial "commenting/graphcomment.html" . -}}
|
{{- partial "page-single/commenting/graphcomment.html" . -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
29
layouts/partials/page-single/commenting/disqus.html
Normal file
29
layouts/partials/page-single/commenting/disqus.html
Normal 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>
|
|
@ -6,11 +6,11 @@
|
||||||
{{.}}
|
{{.}}
|
||||||
</span>
|
</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ partial "post-meta-top.html" . }}
|
{{ partial "page-single/post-meta-top.html" . }}
|
||||||
</header>
|
</header>
|
||||||
<div class="post">
|
<div class="post">
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
{{ partial "post-meta-bottom.html" . }}
|
{{ partial "page-single/post-meta-bottom.html" . }}
|
||||||
{{ partial "post-related.html" . }}
|
{{ partial "page-single/post-related.html" . }}
|
||||||
</article>
|
</article>
|
|
@ -1,10 +1,10 @@
|
||||||
|
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
||||||
|
{{ with $related -}}
|
||||||
<div class="post__related">
|
<div class="post__related">
|
||||||
<!-- related content -->
|
<!-- related content -->
|
||||||
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
|
||||||
{{ with $related }}
|
|
||||||
<h2>Related Articles</h2>
|
<h2>Related Articles</h2>
|
||||||
<ul class="related-posts">
|
<ul class="related-posts">
|
||||||
{{ partial "posts-list.html" . }}
|
{{ partial "posts-list.html" . }}
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
</div>
|
||||||
</div>
|
{{- end }}
|
|
@ -1,22 +1,21 @@
|
||||||
{{ $fig := newScratch }}
|
{{ $fig := newScratch }}
|
||||||
{{ if .Get "caption" }}
|
{{ if .Get "caption" }}
|
||||||
{{ $fig.Set "caption" (.Get "caption") }}
|
{{ $fig.Set "caption" (.Get "caption") }}
|
||||||
{{ else if .Get "alt" }}
|
{{ else if .Get "alt" }}
|
||||||
{{ $fig.Set "caption" (.Get "alt") }}
|
{{ $fig.Set "caption" (.Get "alt") }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
||||||
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
|
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
|
||||||
<img src="{{ .Get "src" }}"
|
<img src="{{ .Get "src" }}"
|
||||||
{{ with $.Scratch.Get "caption" }}alt="{{ . }}"{{ end }}
|
{{ with $.Scratch.Get "caption" }}alt="{{ . }}"{{ end }}
|
||||||
{{ with .Get "align" }}align="{{ . }}"{{ end }}
|
{{ with .Get "align" }}align="{{ . }}"{{ end }}
|
||||||
{{ with .Get "width" }}width="{{ . }}"{{ end }}
|
{{ with .Get "width" }}width="{{ . }}"{{ end }} />
|
||||||
/>
|
{{ with .Get "link"}}</a>{{ end }}
|
||||||
{{ with .Get "link"}}</a>{{ end }}
|
{{ with ($fig.Get "caption") }}
|
||||||
{{ with ($fig.Get "caption") }}
|
|
||||||
<figcaption>
|
<figcaption>
|
||||||
<span class="img--caption">Figure {{ $.Page.Scratch.Get "fig" }}. {{ . }}</span>
|
<span class="img--caption">Figure {{ $.Page.Scratch.Get "fig" }}. {{ . }}</span>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</figure>
|
</figure>
|
||||||
{{ .Page.Scratch.Add "fig" 1 }}
|
{{ .Page.Scratch.Add "fig" 1 }}
|
||||||
{{ $fig.Delete "caption"}}
|
{{ $fig.Delete "caption"}}
|
||||||
|
|
Loading…
Reference in a new issue