diff options
author | kdevo <kdevo@users.noreply.github.com> | 2020-07-12 13:43:13 +0300 |
---|---|---|
committer | kdevo <kdevo@users.noreply.github.com> | 2020-07-12 13:43:13 +0300 |
commit | 700612db2edfc770ff73bffb74be5ad2ba7e2624 (patch) | |
tree | 5e53d26498dffa886dd2f40a89f4ee160db44ce1 /layouts | |
parent | a106983eacecfc4556b82c24b1fbfc09e6539f42 (diff) |
:sparkles: Re-add blog as optional module
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/index.html | 1 | ||||
-rw-r--r-- | layouts/partials/body-bottom.html | 13 | ||||
-rw-r--r-- | layouts/partials/gallery.html | 71 |
3 files changed, 43 insertions, 42 deletions
diff --git a/layouts/index.html b/layouts/index.html index e1afe8c..3849491 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -11,6 +11,7 @@ <!-- Gallery --> {{ if not (eq (len (where .Site.RegularPages "Section" "gallery")) 0) }} {{ partial "gallery.html" . }} + {{ partial "modals.html" . }} {{ end }} <!-- Blog --> diff --git a/layouts/partials/body-bottom.html b/layouts/partials/body-bottom.html index 79864fb..71610b4 100644 --- a/layouts/partials/body-bottom.html +++ b/layouts/partials/body-bottom.html @@ -4,11 +4,20 @@ {{ $scripts = $scripts | append (resources.Get "js/src/termynal.js" | resources.ExecuteAsTemplate "js/src/termynal.js" .) }} {{- end }} {{ if not (eq (len (where .Site.RegularPages "Section" "gallery")) 0) -}} - {{ partial "modals.html" . }} {{ $scripts = $scripts | append (resources.Get "js/src/modal.js" | resources.ExecuteAsTemplate "js/src/modal.js" .) }} {{- end }} {{ $scripts = $scripts | append (resources.Get "js/src/nav.js" | resources.ExecuteAsTemplate "js/src/nav.js" .) }} {{ if (.Site.Params.Feat.ajaxBasin) -}} {{ $scripts = $scripts | append (resources.Get "js/src/contact.js" | resources.ExecuteAsTemplate "js/src/contact.js" .) }} {{- end }} -<script src="{{ ($scripts | resources.Concat "js/bundle.js" | minify | fingerprint).Permalink }}" type="text/javascript"></script> +{{ if .Site.Params.Feat.useBlog -}} + <!-- If using the blog, it is probably worth it to serve a fingerprinted bundle (more page navigations/reloads) --> + <script src="{{ ($scripts | resources.Concat "js/bundle.js" | minify | fingerprint).Permalink }}" type="text/javascript"></script> + <script>handleNavBar({{ .IsHome }})</script> +{{- else -}} + <!-- If not using the blog at all, serving the JS inline will reduce the request count and is probably the best option --> + <script> + {{ ($scripts | resources.Concat "js/bundle.js" | minify).Content | safeJS }} + handleNavBar({{ .IsHome }}) + </script> +{{- end }} diff --git a/layouts/partials/gallery.html b/layouts/partials/gallery.html index c775f72..9431ae2 100644 --- a/layouts/partials/gallery.html +++ b/layouts/partials/gallery.html @@ -1,42 +1,55 @@ <section class="gallery" id="work"> <div class="row"> - <!-- First 4 characters of each gallery page's unique ID --> - {{ range where .Site.RegularPages "Section" "gallery" }} + + {{ $gallery := (where .Site.RegularPages "Section" "gallery") }} + {{ $galleryTotal := len $gallery }} + {{ range $gallery }} <!-- Scratch is used to set page-scoped variable outside of this loop--> - <!-- {{ .Scratch.Set "$modalID" (slicestr .File.UniqueID 0 4) }} --> {{ .Scratch.Set "$modalID" .File.BaseFileName }} - {{ end }} - {{ $galleryTotal := len (where .Site.RegularPages "Section" "gallery") }} - {{ $galleryReverse := (where .Site.RegularPages.Reverse "Section" "gallery") }} - <!-- If gallery is an odd total --> - {{ if not (modBool $galleryTotal 2) }} + {{ if modBool $galleryTotal 2 }} + <!-- If gallery is an even total, all items display evenly in grid columns and rows: --> + {{ range $gallery }} + <!-- If gallery items are greater than 7 and are divisible by 4, + they will appear in columns of 4, else in columns of 2 or 3 --> + <div class="gallery-item col-xs-12 + {{- if gt $galleryTotal 1 }} col-md-6 + {{- if gt $galleryTotal 7 }} + {{- if modBool $galleryTotal 4 }} col-lg-3 + {{- else }} col-lg-4 + {{- end }} + {{- end }} + {{- end }}" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}> + {{ partial "gallery-box.html" . }} + </div> + {{ end }} + {{ else }} + <!-- If gallery is an odd total --> <!-- If gallery is only one item, display it fully --> - {{ if eq $galleryTotal 1 }} - {{ range first 3 $galleryReverse }} + {{ if eq $galleryTotal 1 -}} + {{ range first 3 $gallery }} <div class="gallery-item col-xs-12" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}> {{ partial "gallery-box.html" . }} </div> {{ end }} - {{ end }} + {{- end }} <!-- If gallery is greater than 2 items, first 3 items display together on first row --> - {{ if gt $galleryTotal 2 }} - {{ range first 3 $galleryReverse }} + {{ if gt $galleryTotal 2 -}} + {{ range first 3 $gallery }} <div class="gallery-item col-xs-12 col-md-4" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}> {{ partial "gallery-box.html" . }} </div> {{ end }} - {{ end }} + {{- end }} <!-- If gallery is greater than 3 items, all items after the first 3 display evenly in grid columns and rows --> - {{ if gt $galleryTotal 3 }} - {{ range after 3 $galleryReverse }} - + {{ if gt $galleryTotal 3 -}} + {{ range after 3 $gallery }} <!-- If gallery items are divisible by 3, they will appear in columns of 3 --> {{ $col := (mod $galleryTotal 3) }} <div class="gallery-item col-xs-12 col-md-6 @@ -47,30 +60,8 @@ {{- end }}" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}> {{ partial "gallery-box.html" . }} </div> - {{ end }} - {{ end }} - - {{ end }} - - <!-- If gallery is an even total, all items display evenly in grid columns and rows --> - {{ if modBool $galleryTotal 2 }} - {{ range $galleryReverse }} - - <!-- If gallery items are great than 7 and are divisible by 4, they will appear in columns of 4, else in columns of 2 or 3 --> - <div class="gallery-item col-xs-12 - {{- if gt $galleryTotal 1 }} col-md-6 - {{- if gt $galleryTotal 7 }} - {{- if modBool $galleryTotal 4 }} col-lg-3 - {{- else }} col-lg-4 - {{- end }} - {{- end }} - {{- end }}" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}> - {{ partial "gallery-box.html" . }} - </div> - - {{ end }} + {{- end }} {{ end }} - </div> </section> |