Browse Source

demo: add gallery section

George Cushen 6 years ago
parent
commit
3462cadba1

BIN
exampleSite/content/home/gallery/gallery/theme-1950s.png


BIN
exampleSite/content/home/gallery/gallery/theme-apogee.png


BIN
exampleSite/content/home/gallery/gallery/theme-coffee-playfair.png


BIN
exampleSite/content/home/gallery/gallery/theme-cupcake.png


BIN
exampleSite/content/home/gallery/gallery/theme-dark.png


BIN
exampleSite/content/home/gallery/gallery/theme-default.png


BIN
exampleSite/content/home/gallery/gallery/theme-forest.png


BIN
exampleSite/content/home/gallery/gallery/theme-ocean.png


+ 14 - 0
exampleSite/content/home/gallery/index.md

@@ -0,0 +1,14 @@
++++
+# Custom widget.
+widget = "custom"  # Do not modify this line!
+active = true  # Activate this widget? true/false
+
+# Note: a full width section format can be enabled by commenting out the `title` and `subtitle` with a `#`.
+title = "Gallery"
+subtitle = ""
+
+# Order that this section will appear in.
+weight = 65
++++
+
+{{< gallery >}}

+ 1 - 1
layouts/partials/widgets/slider.html

@@ -37,7 +37,7 @@
           {{ if $item.cta_url }}
           {{ $pack := or .icon_pack "fa" }}
           <p>
-            <a href="{{ $item.cta_url }}" class="btn btn-outline-light btn-lg">
+            <a href="{{ $item.cta_url }}" class="btn btn-light btn-lg">
               {{- with $item.cta_icon -}}<i class="{{ $pack }} {{ $pack }}-{{ . }}" style="padding-right: 10px;"></i>{{- end -}}
               {{- $item.cta_label | emojify | safeHTML -}}
             </a>

+ 8 - 2
layouts/shortcodes/gallery.html

@@ -1,9 +1,11 @@
 {{ $album := "gallery" }}
 {{ with .Get "album" }}{{ $album = . }}{{ end }}
+{{ $album_path := printf "%s/*" $album }}
+{{/* if eq .Page.Type "home" */}}{{/* $album_path = "*" */}}{{/* end */}}
 <div class="gallery">
 
   {{/* Attempt to automatically load gallery images from page bundle */}}
-  {{ $images := ($.Page.Resources.ByType "image").Match (printf "%s/*" $album) }}
+  {{ $images := ($.Page.Resources.ByType "image").Match $album_path }}
   {{ with $images }}
   {{ range $images }}
     {{ $image := .Resize "x190" }}
@@ -23,6 +25,7 @@
   {{else}}
   {{/* Load gallery images from the `static/img/` media library or internet */}}
 
+  {{ if $.Page.Params.gallery_item }}
   {{ range (where $.Page.Params.gallery_item "album" $album) }}
   {{/* Set image path. */}}
   {{ $.Scratch.Set "src" .image }}
@@ -34,6 +37,9 @@
   <a data-fancybox="gallery{{ with .album }}-{{.}}{{ end }}" {{ with .caption }}data-caption="{{.}}"{{ end }} href="{{$.Scratch.Get "src"}}">
     <img src="{{$.Scratch.Get "src"}}" alt="">
   </a>
-  {{ end }}
+  {{end}}
+  {{else}}
+  {{ errorf "Unable to load gallery in %s." .Page.Filename }}
+  {{end}}
   {{end}}
 </div>