diff options
author | Jimmy Cai <jimmehcai@gmail.com> | 2020-08-22 14:20:08 +0300 |
---|---|---|
committer | Jimmy Cai <jimmehcai@gmail.com> | 2020-08-22 14:20:08 +0300 |
commit | c698d944e6b18b4707d96385df9aa0b550d2ec81 (patch) | |
tree | efa66b831e4134092e13677b34775c3cc2dc30a6 /layouts |
:tada: Initial commit
Diffstat (limited to 'layouts')
31 files changed, 679 insertions, 0 deletions
diff --git a/layouts/404.html b/layouts/404.html new file mode 100644 index 0000000..2d4565a --- /dev/null +++ b/layouts/404.html @@ -0,0 +1,13 @@ +{{ define "body_class" }}2-column{{ end }} +{{ define "main" }} +<div class="container extended flex on-phone--column align-items--flex-start"> + {{ partial "sidebar/left.html" . }} + + <main class="main full-width"> + <div class="not-found-card"> + <h1 class="article-title">Not Found</h1> + <h2 class="article-subtitle">This page does not exist.</h2> + </div> + </main> +</div> +{{ end }}
\ No newline at end of file diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..1502c0e --- /dev/null +++ b/layouts/_default/_markup/render-image.html @@ -0,0 +1,18 @@ +{{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}} +{{- $small := $image.Resize "480x" -}} +{{- $big := $image.Resize "1024x" -}} +{{- $alt := .PlainText | safeHTML -}} +{{- $caption := "" -}} +{{- with $alt -}} +{{- $caption = . | safeHTML -}} +{{- end -}} +<figure> + <a href="{{ $image.RelPermalink }}" data-size="{{ $image.Width }}x{{ $image.Height }}"> + <img srcset="{{ $small.RelPermalink }} 480w, {{ $big.RelPermalink }} 1024w" + src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" loading="lazy" + alt="{{ if $alt }}{{ $alt }}{{ else if $caption }}{{ $caption | markdownify | plainify }}{{ else }} {{ end }}"> + </a> + {{ with $caption }} + <figcaption>{{ . | markdownify }}</figcaption> + {{ end }} +</figure>
\ No newline at end of file diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..bb2e8f8 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html lang="{{ .Site.LanguageCode }}"> + {{- partial "head.html" . -}} + <body> + <div id="content"> + {{- block "main" . }}{{- end }} + </div> + {{ partial "footer/script.html" . }} + {{ partial "footer/style.html" . }} + </body> +</html> diff --git a/layouts/_default/single.html b/layouts/_default/single.html new file mode 100644 index 0000000..3fe2859 --- /dev/null +++ b/layouts/_default/single.html @@ -0,0 +1,30 @@ +{{ define "body_class" }}2-column{{ end }} +{{ define "main" }} +<div class="container extended flex on-phone--column align-items--flex-start article-page"> + {{ partial "sidebar/left.html" . }} + + <div class="flex column do-not-overflow"> + <main class="main"> + <div id="article-toolbar"> + <a href="{{ .Site.BaseURL }}" class="back-home"> + {{ (resources.Get "icons/back.svg").Content | safeHTML }} + <span>Back</span> + </a> + </div> + + {{ partial "article/article.html" . }} + + {{ partial "article/components/related-contents" . }} + + {{ if or (not (isset .Params "comments")) (eq .Params.comments "true")}} + {{ partial "article/components/comment" . }} + {{ end }} + + {{ partialCached "footer" . }} + </main> + </div> +</div> + +{{- partial "article/components/photoswipe.html" . -}} + +{{ end }}
\ No newline at end of file diff --git a/layouts/_default/term.html b/layouts/_default/term.html new file mode 100644 index 0000000..cae47d1 --- /dev/null +++ b/layouts/_default/term.html @@ -0,0 +1,41 @@ +{{ define "body_class" }}2-column{{ end }} +{{ define "main" }} +<div class="container extended flex on-phone--column"> + {{ partial "sidebar/left.html" . }} + + <main class="main"> + + <h3 class="taxonomy-type">{{ .Type | singularize | humanize }}</h3> + <div class="taxonomy-card"> + <div class="taxonomy-details"> + <h3 class="taxonomy-count">{{ len .Pages }} post{{ if gt (len .Pages) 1 }}s{{ end }}</h3> + <h1 class="taxonomy-term">{{ .Title }}</h1> + {{ with .Params.description }} + <h2 class="taxonomy-description">{{ . }}</h2> + {{ end }} + </div> + + {{ if .Params.image }} + {{- $image := partial "helper/image" . -}} + {{- $thumbnail := $image.Fill "120x120" -}} + <div class="taxonomy-image"> + <img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}" + height="{{ $thumbnail.Height }}" loading="lazy"> + </div> + {{ end }} + </div> + + <section class="article-list--compact"> + {{ $v2 := where .Pages "Params.hidden" "!=" true }} + {{ $pag := .Paginate (.Pages) }} + {{ range $pag.Pages }} + {{ partial "article-list/compact" . }} + {{ end }} + </section> + + {{- partial "pagination.html" . -}} + + {{ partial "footer" . }} + </main> +</div> +{{ end }}
\ No newline at end of file diff --git a/layouts/index.html b/layouts/index.html new file mode 100644 index 0000000..03af128 --- /dev/null +++ b/layouts/index.html @@ -0,0 +1,25 @@ +{{ define "body_class" }}3-column{{ end }} +{{ define "main" }} +<div class="container extended flex on-phone--column align-items--flex-start"> + {{ partialCached "sidebar/left.html" . }} + + <main class="main full-width"> + {{ $postSection := $.Site.Params.postSection }} + {{ $v1 := where .Site.RegularPages "Section" $postSection }} + {{ $v2 := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $.Scratch.Set "filtered" ($v1 | intersect $v2) }} + {{ $pag := .Paginate ($.Scratch.Get "filtered") }} + + <section class="article-list"> + {{ range $index, $element := $pag.Pages }} + {{ partial "article-list/default" . }} + {{ end }} + {{- partial "pagination.html" . -}} + </section> + + {{ partialCached "footer" . }} + </main> + + {{ partialCached "sidebar/right.html" . }} +</div> +{{ end }}
\ No newline at end of file diff --git a/layouts/page/archive.html b/layouts/page/archive.html new file mode 100644 index 0000000..c63544e --- /dev/null +++ b/layouts/page/archive.html @@ -0,0 +1,39 @@ +{{ define "body_class" }}2-column{{ end }} +{{ define "main" }} +<div class="container extended flex on-phone--column align-items--flex-start"> + + {{ partial "sidebar/left.html" . }} + + <main class="main template-archive"> + <div class="widget"> + <h1 class="widget-title">Categories</h1> + <div class="category-list"> + <div class="article-list--tile"> + {{ range ($.Site.GetPage "taxonomyTerm" "categories").Pages }} + {{ partial "article-list/tile" (dict "context" . "size" "250x150") }} + {{ end }} + </div> + </div> + </div> + + {{ $postSection := $.Site.Params.postSection }} + {{ $v1 := where .Site.RegularPages "Section" $postSection }} + {{ $v2 := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := $v1 | intersect $v2 }} + {{ range $filtered.GroupByDate "2006" }} + {{ $id := lower (replace .Key " " "-") }} + <div class="archive-group" id="{{ $id }}"> + <h3 class="archive-date"><a href="{{ $.Permalink }}#{{ $id }}">{{ .Key }}</a></h3> + <div class="article-list--compact"> + {{ range .Pages }} + {{ partial "article-list/compact" . }} + {{ end }} + </div> + </div> + {{ end }} + + {{ partial "footer.html" . }} + </main> +</div> + +{{ end }}
\ No newline at end of file diff --git a/layouts/page/single.html b/layouts/page/single.html new file mode 100644 index 0000000..d1791f0 --- /dev/null +++ b/layouts/page/single.html @@ -0,0 +1,18 @@ +{{ define "body_class" }}2-column{{ end }} +{{ define "main" }} +<div class="container extended flex on-phone--column align-items--flex-start article-and-sidebar"> + + {{ partial "sidebar/left.html" . }} + + <main class="main article-page do-not-overflow full-width"> + {{ partial "article/article.html" . }} + + {{ if or (not (isset .Params "comments")) (eq .Params.comments "true")}} + {{ partial "article/components/comment" . }} + {{ end }} + </main> +</div> + +{{ partial "article/components/photoswipe" . }} + +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/article-list/compact.html b/layouts/partials/article-list/compact.html new file mode 100644 index 0000000..02fc0b3 --- /dev/null +++ b/layouts/partials/article-list/compact.html @@ -0,0 +1,24 @@ +<article> + <div class="article-details"> + <h2 class="article-title"> + <a href="{{ .Permalink }}"> + {{- .Title -}} + </a> + </h2> + <footer class="article-time"> + <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'> + {{- .Date.Format ( or .Site.Params.dateFormat "Jan 02, 2006" ) -}} + </time> + </footer> + </div> + + {{ if .Params.image }} + {{- $image := partial "helper/image" . -}} + {{- $thumbnail := $image.Fill "120x120" -}} + + <div class="article-image"> + <img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}" + height="{{ $thumbnail.Height }}" loading="lazy"> + </div> + {{ end }} +</article>
\ No newline at end of file diff --git a/layouts/partials/article-list/default.html b/layouts/partials/article-list/default.html new file mode 100644 index 0000000..ed9fc43 --- /dev/null +++ b/layouts/partials/article-list/default.html @@ -0,0 +1,51 @@ +<article class="{{ if .Params.image }}has-image{{ end }}"> + {{ if .Params.image }} + {{- $image := partial "helper/image" . -}} + {{- $thumbnailNotDesktop := $image.Resize "x500 smart" -}} + + <div class="article-image"> + <img src="{{ $thumbnailNotDesktop.RelPermalink }}" + width="{{ $thumbnailNotDesktop.Width }}" height="{{ $thumbnailNotDesktop.Height }}" loading="lazy" + alt="Featured image of post {{ .Title }}" /> + </div> + {{ end }} + + {{ $i := .Params.image }} + {{ $context := . }} + + <div class="article-details"> + {{ with $categories := .Params.categories }} + <header class="article-category"> + {{ range first 1 $categories }} + {{ if $i }} + {{- $image := partial "helper/image" $context -}} + {{- $20x := $image.Fill "20x20 smart" -}} + <a href="/categories/{{ . | urlize }}" class="color-tag" + data-image="{{ $20x.RelPermalink }}">{{ . | humanize }}</a> + {{ else }} + <a href="/categories/{{ . | urlize }}">{{ . | humanize }}</a> + {{ end }} + {{ end }} + </header> + {{ end }} + + <h2 class="article-title"> + <a href="{{ .Permalink }}"> + {{- .Title -}} + </a> + </h2> + + {{ with .Params.description }} + <h3 class="article-subtitle"> + {{ . }} + </h3> + {{ end }} + + <footer class="article-time"> + {{ (resources.Get "icons/clock.svg").Content | safeHTML }} + <time data-timeago="true" datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'> + {{- .Date.Format ( or .Site.Params.dateFormat "Jan 02, 2006" ) -}} + </time> + </footer> + </div> +</article>
\ No newline at end of file diff --git a/layouts/partials/article-list/tile.html b/layouts/partials/article-list/tile.html new file mode 100644 index 0000000..1602651 --- /dev/null +++ b/layouts/partials/article-list/tile.html @@ -0,0 +1,17 @@ +<article class="{{ if .context.Params.image }}has-image{{ end }}"> + <a href="{{ .context.Permalink }}"> + {{ if .context.Params.image }} + {{- $thumbnail := (partial "helper/image" (.context) ).Fill .size -}} + <div class="article-image"> + <img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" + loading="lazy"> + </div> + {{ end }} + + <div class="article-details"> + <h2 class="article-title"> + {{- .context.Title -}} + </h2> + </div> + </a> +</article>
\ No newline at end of file diff --git a/layouts/partials/article/article.html b/layouts/partials/article/article.html new file mode 100644 index 0000000..6748188 --- /dev/null +++ b/layouts/partials/article/article.html @@ -0,0 +1,75 @@ +<article class="{{ if .Params.image }}has-image{{ end }} main-article"> + <header class="article-header"> + {{ if .Params.image }} + {{- $image := partial "helper/image" . -}} + + {{- $tablet := $image.Resize "1024x" -}} + {{- $desktop := $image.Resize "2000x" -}} + + {{- $20x := $image.Fill "20x20 smart" -}} + {{- .Scratch.Set "20x" $20x -}} + + <div class="article-image"> + <img srcset="{{ $tablet.RelPermalink }} 1024w, {{ $desktop.RelPermalink }} 2000w" + src="{{ $desktop.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" + loading="lazy" + alt="Featured image of post {{ .Title }}" /> + </div> + {{ end }} + + <div class="article-details"> + {{ with $category := .Params.categories }} + <header class="article-category"> + {{ range first 1 $category }} + {{ if $.Params.image }} + <a href="/categories/{{ . | urlize }}" class="color-tag" + data-image="{{ ($.Scratch.Get "20x").RelPermalink }}">{{ . | humanize }}</a> + {{ else }} + <a href="/categories/{{ . | urlize }}">{{ . | humanize }}</a> + {{ end }} + {{ end }} + </header> + {{ end }} + + <h2 class="article-title"> + <a href="{{ .Permalink }}"> + {{- .Title -}} + </a> + </h2> + + {{ with .Params.description }} + <h3 class="article-subtitle"> + {{ . }} + </h3> + {{ end }} + + <footer class="article-time"> + {{ (resources.Get "icons/clock.svg").Content | safeHTML }} + <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'> + {{- .Date.Format ( or .Site.Params.dateFormat "Jan 02, 2006" ) -}} + </time> + </footer> + </div> + </header> + + <section class="article-content"> + {{ .Content }} + </section> + + <footer class="article-footer"> + {{ with $tags := .Params.Tags }} + <section class="article-tags"> + {{ range $tags }} + <a href="/tags/{{ . | urlize }}">{{ . | humanize }}</a> + {{ end }} + </section> + {{ end }} + + {{ if .Site.Params.postLicense }} + <section class="article-copyright"> + {{ (resources.Get "icons/copyright.svg").Content | safeHTML }} + <span>{{ .Site.Params.postLicense }}</span> + </section> + {{ end }} + </footer> +</article>
\ No newline at end of file diff --git a/layouts/partials/article/components/comment.html b/layouts/partials/article/components/comment.html new file mode 100644 index 0000000..393568b --- /dev/null +++ b/layouts/partials/article/components/comment.html @@ -0,0 +1 @@ +{{ template "_internal/disqus.html" . }}
\ No newline at end of file diff --git a/layouts/partials/article/components/photoswipe.html b/layouts/partials/article/components/photoswipe.html new file mode 100644 index 0000000..290872c --- /dev/null +++ b/layouts/partials/article/components/photoswipe.html @@ -0,0 +1,66 @@ +<!-- Root element of PhotoSwipe. Must have class pswp. --> +<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true" style="display:none"> + + <!-- Background of PhotoSwipe. + It's a separate element as animating opacity is faster than rgba(). --> + <div class="pswp__bg"></div> + + <!-- Slides wrapper with overflow:hidden. --> + <div class="pswp__scroll-wrap"> + + <!-- Container that holds slides. + PhotoSwipe keeps only 3 of them in the DOM to save memory. + Don't modify these 3 pswp__item elements, data is added later on. --> + <div class="pswp__container"> + <div class="pswp__item"></div> + <div class="pswp__item"></div> + <div class="pswp__item"></div> + </div> + + <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. --> + <div class="pswp__ui pswp__ui--hidden"> + + <div class="pswp__top-bar"> + + <!-- Controls are self-explanatory. Order can be changed. --> + + <div class="pswp__counter"></div> + + <button class="pswp__button pswp__button--close" title="Close (Esc)"></button> + + <button class="pswp__button pswp__button--share" title="Share"></button> + + <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button> + + <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button> + + <!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR --> + <!-- element will get class pswp__preloader--active when preloader is running --> + <div class="pswp__preloader"> + <div class="pswp__preloader__icn"> + <div class="pswp__preloader__cut"> + <div class="pswp__preloader__donut"></div> + </div> + </div> + </div> + </div> + + <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"> + <div class="pswp__share-tooltip"></div> + </div> + + <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"> + </button> + + <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"> + </button> + + <div class="pswp__caption"> + <div class="pswp__caption__center"></div> + </div> + + </div> + + </div> + +</div>
\ No newline at end of file diff --git a/layouts/partials/article/components/related-contents.html b/layouts/partials/article/components/related-contents.html new file mode 100644 index 0000000..972c979 --- /dev/null +++ b/layouts/partials/article/components/related-contents.html @@ -0,0 +1,13 @@ +<aside class="widget related-contents--wrapper"> + {{ $related := .Site.RegularPages.Related . | first 5 }} + {{ with $related }} + <h1 class="widget-title">Related contents</h1> + <div class="related-contents"> + <div class="flex article-list--tile"> + {{ range . }} + {{ partial "article-list/tile" (dict "context" . "size" "250x350") }} + {{ end }} + </div> + </div> + {{ end }} +</aside>
\ No newline at end of file diff --git a/layouts/partials/data/description.html b/layouts/partials/data/description.html new file mode 100644 index 0000000..5531ab5 --- /dev/null +++ b/layouts/partials/data/description.html @@ -0,0 +1,11 @@ +{{- with .Description -}} + {{- . -}} +{{- else -}} + {{- if .IsPage -}} + {{- .Summary -}} + {{- else -}} + {{- with .Site.Params.subtitle -}} + {{- . -}} + {{- end -}} + {{- end -}} +{{- end -}}
\ No newline at end of file diff --git a/layouts/partials/data/title.html b/layouts/partials/data/title.html new file mode 100644 index 0000000..7249649 --- /dev/null +++ b/layouts/partials/data/title.html @@ -0,0 +1,16 @@ +{{- $title := .Title -}} +{{- $siteTitle := .Site.Title -}} +{{- $authorName := .Site.Author.name -}} + +{{- if .IsHome -}} + {{- $v1 := where .Site.RegularPages "Type" "post" -}} + {{- $v2 := where .Site.RegularPages "Params.hidden" "!=" true -}} + {{- $filtered := $v1 | intersect $v2 -}} + {{- $pag := .Paginate ($filtered) -}} + {{ if .Paginator.HasPrev }}{{ .Paginator }} - {{ end }}{{ $siteTitle }} +{{- else if eq .Kind "term" -}} + {{- $pag := .Paginate (where .Data.Pages "Type" "post") -}} + {{ title .Data.Singular }}: {{ $title }}{{ if .Paginator.HasPrev }} - {{ .Paginator }}{{ end }} - {{ $siteTitle }} +{{- else -}} + {{- $title -}} +{{- end -}}
\ No newline at end of file diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html new file mode 100644 index 0000000..a1be85f --- /dev/null +++ b/layouts/partials/footer.html @@ -0,0 +1,7 @@ +<footer class="site-footer"> + <section class="copyright">© {{ now.Format "2006" }} {{ .Site.Title }}</section> + <section class="powerby"> + Built with <a href="https://gohugo.io/" target="_blank">Hugo</a> <br /> + Theme <b>Stack</b> designed by <a href="https://jimmycai.com" target="_blank">Jimmy</a> + </section> +</footer>
\ No newline at end of file diff --git a/layouts/partials/footer/script.html b/layouts/partials/footer/script.html new file mode 100644 index 0000000..50cef14 --- /dev/null +++ b/layouts/partials/footer/script.html @@ -0,0 +1,15 @@ +<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.2/timeago.min.js" + integrity="sha512-SVDh1zH5N9ChofSlNAK43lcNS7lWze6DTVx1JCXH1Tmno+0/1jMpdbR8YDgDUfcUrPp1xyE53G42GFrcM0CMVg==" + crossorigin="anonymous"></script> + +<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-JavaScript-Templates/3.18.0/js/tmpl.min.js" + integrity="sha512-62X328c9VQQkWxrLMccNyRISbwvqQDjvF/HFuvHBMGtZJbNvTG30k1M2O+PYLyWUrcHFKIPvr2OkgmUmcaiccw==" + crossorigin="anonymous"></script>--> + +<script src="https://cdn.jsdelivr.net/npm/node-vibrant@3.1.5/dist/vibrant.min.js" + integrity="sha256-5NovOZc4iwiAWTYIFiIM7DxKUXKWvpVEuMEPLzcm5/g=" crossorigin="anonymous"></script> + +{{ $opts := dict "minify" hugo.IsProduction }} +{{ $script := resources.Get "ts/main.ts" | js.Build $opts }} + +<script type="text/javascript" src="{{ $script.RelPermalink }}" defer></script>
\ No newline at end of file diff --git a/layouts/partials/footer/style.html b/layouts/partials/footer/style.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/partials/footer/style.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..6543065 --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,18 @@ +<head> + <meta charset='utf-8'> + <meta name='viewport' content='width=device-width, initial-scale=1'> + <meta name='description' content='{{ chomp (partial "data/description" . | plainify ) }}'> + <base href='{{ .Site.BaseURL }}'> + + <title>{{ (trim (partial "data/title" .) "\n" ) | safeHTML }}</title> + <link rel='canonical' href='{{ .Permalink }}'> + + {{ partial "head/style.html" . }} + {{ partial "head/script.html" . }} + + {{ partial "head/opengraph.html" . }} + + {{ range .AlternativeOutputFormats -}} + <link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}"> + {{ end -}} +</head>
\ No newline at end of file diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/head/opengraph.html new file mode 100644 index 0000000..4e9c368 --- /dev/null +++ b/layouts/partials/head/opengraph.html @@ -0,0 +1,51 @@ +<meta property='og:title' content='{{ partial "data/title" . }}'> +<meta property='og:description' content='{{ chomp (partial "data/description" . | plainify ) }}'> +<meta property='og:url' content='{{ .Permalink }}'> +<meta property='og:site_name' content='{{ .Site.Title }}'> +<meta property='og:type' content=' + {{- if .IsPage -}} + article + {{- else -}} + website + {{- end -}} +'> + +{{ with .Site.Params.twitter }} +<meta name="twitter:site" content="{{ . }}"> +{{ end }} +<meta name="twitter:title" content="{{ partial "data/title" . }}"> +<meta name="twitter:description" content="{{ chomp (partial "data/description" . | plainify ) }}"> + +{{- with .Params.locale -}} + <meta property='og:locale' content='{{ . }}'> +{{- end -}} + +{{- if .IsPage -}} + <meta property='article:section' content='{{ .Section | title }}' /> + {{- range .Params.tags -}} + <meta property='article:tag' content='{{ . }}' /> + {{- end -}} +{{- end -}} + +{{- if .IsPage -}} + {{- if not .Date.IsZero -}} + <meta property='article:published_time' content='{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}'/> + {{- end -}} + {{- if not .Lastmod.IsZero -}} + <meta property='article:modified_time' content='{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}'/> + {{- end -}} +{{- else -}} + {{- if not .Site.LastChange.IsZero -}} + <meta property='og:updated_time' content='{{ .Site.LastChange.Format " 2006-01-02T15:04:05-07:00 " | safeHTML }}'/> + {{- end -}} +{{- end -}} + +<meta name="twitter:card" content="summary_large_image"> + +{{- if .Params.image -}} + {{ $image := partial "helper/image" . }} + <meta property='og:image' content='{{ absURL $image.RelPermalink }}' /> + <meta name="twitter:image" content='{{ absURL $image.RelPermalink }}' /> +{{- else -}} + <meta property='og:image' content='{{ absURL .Site.Params.logo }}' /> +{{- end -}}
\ No newline at end of file diff --git a/layouts/partials/head/script.html b/layouts/partials/head/script.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/partials/head/script.html diff --git a/layouts/partials/head/style.html b/layouts/partials/head/style.html new file mode 100644 index 0000000..3dfc2bd --- /dev/null +++ b/layouts/partials/head/style.html @@ -0,0 +1,5 @@ +<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap" rel="stylesheet"> + +{{ $sass := resources.Get "scss/style.scss" }} +{{ $style := $sass | resources.ToCSS | minify }} +<link rel="stylesheet" href="{{ $style.Permalink }}">
\ No newline at end of file diff --git a/layouts/partials/helper/image.html b/layouts/partials/helper/image.html new file mode 100644 index 0000000..308a36c --- /dev/null +++ b/layouts/partials/helper/image.html @@ -0,0 +1,2 @@ +{{- $image := .Resources.GetMatch (printf "%s" (.Params.image | safeURL)) -}} +{{ return $image }}
\ No newline at end of file diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 0000000..7756050 --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,26 @@ +{{ if gt .Paginator.TotalPages 1 }} + <nav class='pagination'> + {{ $.Scratch.Set "hasPrevDots" false }} + {{ $.Scratch.Set "hasNextDots" false }} + + {{ range .Paginator.Pagers }} + {{ if eq . $.Paginator }} + <span class='page-link current'> + {{- .PageNumber -}} + </span> + {{ else if or (or (eq . $.Paginator.First) (eq . $.Paginator.Prev)) (or (eq . $.Paginator.Next) (eq . $.Paginator.Last )) }} + <a class='page-link' href='{{ .URL }}'> + {{- .PageNumber -}} + </a> + {{ else }} + {{ if and (not ($.Scratch.Get "hasPrevDots")) (lt .PageNumber $.Paginator.PageNumber) }} + {{ $.Scratch.Set "hasPrevDots" true }} + <span class='page-link dots'>…</span> + {{ else if and (not ($.Scratch.Get "hasNextDots")) (gt .PageNumber $.Paginator.PageNumber) }} + {{ $.Scratch.Set "hasNextDots" true }} + <span class='page-link dots'>…</span> + {{ end }} + {{ end }} + {{ end }} + </nav> +{{ end }} diff --git a/layouts/partials/sidebar/left.html b/layouts/partials/sidebar/left.html new file mode 100644 index 0000000..ff536a8 --- /dev/null +++ b/layouts/partials/sidebar/left.html @@ -0,0 +1,33 @@ +<aside class="sidebar left-sidebar sticky"> + <button class="hamburger hamburger--spin" type="button" id="toggle-menu" aria-label="Toggle Menu"> + <span class="hamburger-box"> + <span class="hamburger-inner"></span> + </span> + </button> + + <header class="site-info"> + <figure class="site-avatar"> + {{ $avatar := resources.Get (.Site.Params.avatar) }} + {{ $avatarResized := $avatar.Resize "300x300" }} + <img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}" + height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar"> + <span class="emoji">{{ .Site.Params.emoji }}</span> + </figure> + <h1 class="site-name"><a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a></h1> + <h2 class="site-description">{{ .Site.Params.subtitle }}</h2> + </header> + + <nav class="menu" id="main-menu"> + {{ $currentPage := . }} + {{ range .Site.Menus.main }} + {{ $active := or (eq $currentPage.Title .Name) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }} + + <li {{ if $active }} class='current' {{ end }}> + <a href='{{ .URL }}'> + {{ (resources.Get (delimit (slice "icons/" .Pre ".svg") "")).Content | safeHTML }} + <span>{{- .Name -}}</span> + </a> + </li> + {{ end }} + </nav> +</aside>
\ No newline at end of file diff --git a/layouts/partials/sidebar/right.html b/layouts/partials/sidebar/right.html new file mode 100644 index 0000000..24763bb --- /dev/null +++ b/layouts/partials/sidebar/right.html @@ -0,0 +1,8 @@ +{{ if .Site.Params.widgets.enabled }} + {{ $context := . }} + <aside class="sidebar right-sidebar sticky"> + {{ range $widget := .Site.Params.widgets.enabled }} + {{ partial (printf "widget/%s" $widget) $context }} + {{ end }} + </aside> +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/widget/archive.html b/layouts/partials/widget/archive.html new file mode 100644 index 0000000..cfe02df --- /dev/null +++ b/layouts/partials/widget/archive.html @@ -0,0 +1,19 @@ +<section class="widget archive"> + <div class="widget-icon"> + {{ (resources.Get "icons/infinity.svg").Content | safeHTML }} + </div> + <h1 class="widget-title">Archive</h1> + + {{ $v1 := where .Site.RegularPages "Section" "post" }} + {{ $v2 := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := $v1 | intersect $v2 }} + {{ range $filtered.GroupByDate "2006" }} + {{ $id := lower (replace .Key " " "-") }} + <div class="archive-year"> + <a href="{{ $.Site.BaseURL }}/archive#{{ $id }}"> + <span class="year">{{ .Key }}</span> + <span class="count">{{ len .Pages }}</span> + </a> + </div> + {{ end }} +</section> diff --git a/layouts/partials/widget/tag-cloud.html b/layouts/partials/widget/tag-cloud.html new file mode 100644 index 0000000..1dcddfc --- /dev/null +++ b/layouts/partials/widget/tag-cloud.html @@ -0,0 +1,17 @@ +{{ $tags := .Site.Taxonomies.tags.ByCount }} +{{ $v2 := where $tags "Term" "not in" (slice "hugo" "tag" "rss") }} + +<section class="widget tagCloud"> + <div class="widget-icon"> + {{ (resources.Get "icons/tag.svg").Content | safeHTML }} + </div> + <h1 class="widget-title">Tags</h1> + + <div class="tagCloud-tags"> + {{ range first .Site.Params.widgets.tagCloud.limit $v2 }} + <a href="{{ $.Site.BaseURL }}tags/{{ .Term | urlize }}/" class="font_size_{{ .Count }}"> + {{ .Term | humanize }} + </a> + {{ end }} + </div> +</section>
\ No newline at end of file diff --git a/layouts/shortcodes/youtube.html b/layouts/shortcodes/youtube.html new file mode 100644 index 0000000..5dd94e6 --- /dev/null +++ b/layouts/shortcodes/youtube.html @@ -0,0 +1,9 @@ +{{- $pc := .Page.Site.Config.Privacy.YouTube -}} +{{- if not $pc.Disable -}} +{{- $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" -}} +{{- $id := .Get "id" | default (.Get 0) -}} +{{- $class := .Get "class" | default (.Get 1) }} +<div {{ with $class }}class="{{ . }}"{{ else }}style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"{{ end }}> + <iframe loading="lazy" src="https://{{ $ytHost }}/embed/{{ $id }}{{ with .Get "autoplay" }}{{ if eq . "true" }}?autoplay=1{{ end }}{{ end }}" {{ if not $class }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" {{ end }}allowfullscreen title="YouTube Video"></iframe> +</div> +{{ end -}}
\ No newline at end of file |