hugo-theme-zzo/layouts/_default/single.html

96 lines
3.6 KiB
HTML
Raw Normal View History

2019-11-04 13:09:44 +00:00
{{ define "main" }}
2019-12-08 14:29:02 +00:00
{{ $enquire := resources.Get "js/enquire.min.js" | resources.Fingerprint }}
<script src="{{ $enquire.RelPermalink }}"></script>
<main class="single__main {{ if or ($.Param "enableToc") ($.Param "toc") }}{{ if $.Param "hideToc" }}main{{ else if eq ($.Param "tocPosition") "outer" }}main{{ else }}main-main{{ end }}{{ else }}main{{ end }}">
2019-11-04 13:09:44 +00:00
{{ if eq .Site.Params.enableBreadcrumb true }}
{{ partial "body/breadcrumb" . }}
{{ end }}
<div class="single">
<h2 class="single__title">{{ .Title }}</h2>
2019-11-04 13:09:44 +00:00
<div class="single__meta">
2019-12-05 13:57:05 +00:00
{{ partial "body/infos" . }}
{{ partial "body/tags" . }}
</div>
2019-11-04 13:09:44 +00:00
<article class="single__contents">
2020-01-07 07:30:51 +00:00
{{ partial "body/toc" . }}
2019-11-04 13:09:44 +00:00
{{ .Content }}
</article>
{{ partial "body/share" . }}
{{ partial "body/donation" . }}
2019-11-20 06:55:05 +00:00
{{ partial "body/whoami" . }}
2019-11-04 13:09:44 +00:00
{{ partial "body/related" . }}
{{ partial "pagination/pagination-single" . }}
2019-11-20 06:55:05 +00:00
{{ partial "comments/comments.html" . }}
{{ partial "body/photoswipe" . }}
<div class="hide">
2020-01-21 02:07:47 +00:00
{{ partial "search/site-search" . }}
</div>
2019-11-04 13:09:44 +00:00
</div>
</main>
{{ if and (or ($.Param "enableToc") ($.Param "toc")) (ne ($.Param "tocPosition") "outer") }}
2020-01-21 02:07:47 +00:00
<aside class="single__side {{ if or ($.Param "enableToc") ($.Param "toc") }}main-side{{ end }}">
2019-11-04 13:09:44 +00:00
{{ partial "sidebar/sidebar-single" . }}
</aside>
{{ end }}
2019-12-08 14:29:02 +00:00
<script>
2020-01-21 02:07:47 +00:00
{{ $enableToc:= $.Param "enableToc" }}
{{ $toc:= $.Param "toc" }}
{{ $tocPosition:= $.Param "tocPosition" }}
2020-01-21 02:07:47 +00:00
var enableToc = JSON.parse({{ $enableToc | jsonify }});
var toc = JSON.parse({{ $toc | jsonify }});
var tocPosition = JSON.parse({{ $tocPosition | jsonify }});
2020-01-21 02:07:47 +00:00
var singleMainElem = document.querySelector('.single__main');
var singleSideElem = document.querySelector('.single__side');
2019-12-08 14:29:02 +00:00
enquire.register("screen and (max-width: 769px)", {
match: function () {
if ((enableToc || toc) && tocPosition !== "outer") {
if (singleMainElem && singleSideElem) {
singleMainElem.classList.remove('main-main');
singleMainElem.classList.add('main');
singleSideElem.classList.remove('main-side');
singleSideElem.classList.add('hide');
}
} else if (tocPosition === "outer") {
if (singleMainElem && !singleMainElem.classList.contains('main-main')) {
singleMainElem.classList.remove('main-main');
singleMainElem.classList.add('main');
}
if (singleSideElem && !singleSideElem.classList.contains('hide')) {
singleSideElem.classList.add('hide');
}
2019-12-08 14:29:02 +00:00
}
},
unmatch: function () {
if ((enableToc || toc) && tocPosition !== "outer") {
2020-01-21 02:07:47 +00:00
singleMainElem.classList.remove('main');
singleMainElem.classList.add('main-main');
singleSideElem.classList.remove('hide');
singleSideElem.classList.add('main-side');
} else if (tocPosition === "outer") {
if (singleMainElem && !singleMainElem.classList.contains('main-main')) {
singleMainElem.classList.remove('main-main');
singleMainElem.classList.add('main');
}
if (singleSideElem && !singleSideElem.classList.contains('hide')) {
singleSideElem.classList.add('hide');
}
2019-12-08 14:29:02 +00:00
}
2020-01-21 02:07:47 +00:00
2019-12-08 14:29:02 +00:00
document.getElementsByClassName('navbar__burger')[0].classList.remove('is-active');
document.getElementsByClassName('navbar__menu')[0].classList.remove('is-active');
document.getElementsByClassName('mobile-search')[0].classList.add('hide');
},
setup: function () { },
deferSetup: true,
destroy: function () { },
});
</script>
{{ partial "script/single-script" . }}
{{ end }}