Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Chen-Zhe/photo-grid.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Zhe <chenzhesg@gmail.com>2021-01-29 20:28:10 +0300
committerChen Zhe <chenzhesg@gmail.com>2021-01-29 20:28:10 +0300
commit3dd7f0ce3edd4d2f676a8c5c5884a082a76dc2fb (patch)
tree1fdd918c5796ac7cc34e304c0693d538c7513132 /layouts
parentbfe9327b0258f2dda2c4e880ed2bea589de6a580 (diff)
Add embedded video support
Diffstat (limited to 'layouts')
-rw-r--r--layouts/index.html19
-rw-r--r--layouts/partials/helper/icon.html6
2 files changed, 18 insertions, 7 deletions
diff --git a/layouts/index.html b/layouts/index.html
index 3a41a46..0958352 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -9,14 +9,16 @@
{{ partial "header.html" . }}
<div class="main">
<ul id="og-grid" class="og-grid">
- {{ range $page := sort (where .Site.RegularPages "Type" "photo") ".File.Dir" }}
- {{ range $index, $image := sort ($page.Resources.ByType "image") "Params.order" }}
+ {{- range $page := sort (where .Site.RegularPages "Type" "photo") ".File.Dir" }}
+ {{- range $index, $image := sort ($page.Resources.ByType "image") "Params.order" }}
+ {{- $isVideo := isset $image.Params "video_embed_link" }}
<li>
- <a href="{{ if isset $image.Params "button_url" }}{{ $image.Params.button_url }}{{ else }}#{{ end }}" data-largesrc="{{ $image.RelPermalink }}"
+ <a href="{{ if isset $image.Params "button_url" }}{{ $image.Params.button_url }}{{ else }}#{{ end }}" data-largesrc="{{ if $isVideo }}{{ $image.Params.video_embed_link }}{{ else }}{{ $image.RelPermalink }}{{ end }}"
data-title="{{ $image.Name }}"
+ data-is-video="{{ $isVideo }}"
data-description="{{ $image.Params.description | markdownify }}"
{{ if isset $image.Params "button_text" }}data-buttontext="{{ $image.Params.button_text }}"{{ end }} data-collection="{{ $page.Title }}"
- {{ if not $.Site.Params.no_exif }}
+ {{ if and (not $.Site.Params.no_exif) (not $isVideo) -}}
data-exif="{{ if in (slice "jpg" "jpeg" "tiff" "tif") $image.MediaType.SubType }}
{{- with $image.Exif -}}
{{- with .Tags -}}
@@ -34,12 +36,15 @@
<li>Taken at {{ if isset $image.Params "timestamp" }} {{ $image.Params.timestamp }} {{ else }}{{ .Date.Format "2006-1-2 15:04" }}{{ end }}</li>
{{- end }}
{{- end }}"{{ end }}>
- {{ $.Scratch.Set "thumbnail" ($image.Resize "x250") }}
+ {{- if $isVideo -}}
+ <span class="video-icon">{{ partial "helper/icon" "video" }}</span>
+ {{- end -}}
+ {{- $.Scratch.Set "thumbnail" ($image.Resize "x250") -}}
<img class="lazy" data-src="{{ ($.Scratch.Get "thumbnail").RelPermalink }}" style="width:{{ ($.Scratch.Get "thumbnail").Width }}px;" alt="Thumbnail of {{ $image.Name }}"/>
</a>
</li>
- {{ end }}
- {{ end }}
+ {{- end -}}
+ {{- end -}}
</ul>
{{ partial "footer.html" . }}
</div>
diff --git a/layouts/partials/helper/icon.html b/layouts/partials/helper/icon.html
new file mode 100644
index 0000000..72162e8
--- /dev/null
+++ b/layouts/partials/helper/icon.html
@@ -0,0 +1,6 @@
+{{- $iconFile := resources.GetMatch (printf "icons/%s.svg" .) -}}
+{{- if $iconFile -}}
+ {{- $iconFile.Content | safeHTML -}}
+{{- else -}}
+ {{- errorf "Error: icon '%s.svg' is not found under 'assets/icons' folder" . -}}
+{{- end -}} \ No newline at end of file