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 -}}
|
||||
|
||||
{{ define "content" -}}
|
||||
{{ partial "page-list.html" . }}
|
||||
{{ partial "page-list/content.html" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{ define "footer" -}}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
{{ define "header" -}}
|
||||
{{ partial "page-variables-init.html" . }}
|
||||
{{ partial "page-single/variables-init.html" . }}
|
||||
{{ partial "header.html" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{ define "content" -}}
|
||||
{{ partial "page-single.html" . }}
|
||||
{{ partial "page-single/content.html" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{ define "footer" -}}
|
||||
<div class="container content">
|
||||
{{- partial "highlight-js.html" . -}}
|
||||
{{- partial "commenting.html" . -}}
|
||||
{{- partial "page-single/commenting.html" . -}}
|
||||
</div>
|
||||
{{- partial "highlight-js.html" . -}}
|
||||
{{ partial "footer.html" . }}
|
||||
{{ partial "page-variables-deinit.html" . }}
|
||||
{{ partial "page-single/variables-deinit.html" . }}
|
||||
{{- 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) -}}
|
||||
{{ "<!-- Google Analytics -->" | safeHTML }}
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
<!-- Google Analytics -->
|
||||
{{- template "_internal/google_analytics_async.html" . -}}
|
||||
{{- 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>
|
||||
<link href="http://gmpg.org/xfn/11" rel="profile">
|
||||
{{ partial "header/meta.html" . }}
|
||||
{{ partial "header/highlight-css.html" . }}
|
||||
<link rel="stylesheet" href="{{ .Site.BaseURL }}/css/print.min.css" media="print">
|
||||
<link rel="stylesheet" href="{{ .Site.BaseURL }}/css/hyde-hyde.css">
|
||||
{{ partial "header/styles.html" . }}
|
||||
{{ `<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{- 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">
|
||||
{{- end -}}
|
||||
{{ 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 .Site.DisqusShortname -}}
|
||||
{{- partial "commenting/disqus.html" . -}}
|
||||
{{- partial "page-single/commenting/disqus.html" . -}}
|
||||
{{- else if .Site.Params.GraphCommentId -}}
|
||||
{{- partial "commenting/graphcomment.html" . -}}
|
||||
{{- partial "page-single/commenting/graphcomment.html" . -}}
|
||||
{{- 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>
|
||||
{{ end }}
|
||||
{{ partial "post-meta-top.html" . }}
|
||||
{{ partial "page-single/post-meta-top.html" . }}
|
||||
</header>
|
||||
<div class="post">
|
||||
{{ .Content }}
|
||||
</div>
|
||||
{{ partial "post-meta-bottom.html" . }}
|
||||
{{ partial "post-related.html" . }}
|
||||
{{ partial "page-single/post-meta-bottom.html" . }}
|
||||
{{ partial "page-single/post-related.html" . }}
|
||||
</article>
|
|
@ -1,10 +1,10 @@
|
|||
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
||||
{{ with $related -}}
|
||||
<div class="post__related">
|
||||
<!-- related content -->
|
||||
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
||||
{{ with $related }}
|
||||
<h2>Related Articles</h2>
|
||||
<ul class="related-posts">
|
||||
{{ partial "posts-list.html" . }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{- end }}
|
|
@ -9,8 +9,7 @@
|
|||
<img src="{{ .Get "src" }}"
|
||||
{{ with $.Scratch.Get "caption" }}alt="{{ . }}"{{ end }}
|
||||
{{ with .Get "align" }}align="{{ . }}"{{ end }}
|
||||
{{ with .Get "width" }}width="{{ . }}"{{ end }}
|
||||
/>
|
||||
{{ with .Get "width" }}width="{{ . }}"{{ end }} />
|
||||
{{ with .Get "link"}}</a>{{ end }}
|
||||
{{ with ($fig.Get "caption") }}
|
||||
<figcaption>
|
||||
|
|
Loading…
Reference in a new issue