Skip to content

Commit

Permalink
viewer js integration for gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
gurusabarish committed Jun 15, 2024
1 parent d3755c8 commit 236b319
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
5 changes: 5 additions & 0 deletions exampleSite/content/gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ galleryImages:
- src: https://thumbs.dreamstime.com/b/summer-day-smiling-women-relax-wearing-red-dress-fashion-standing-wooden-bridge-over-sea-blue-sky-background-summer-107411998.jpg
- src: https://thumbs.dreamstime.com/b/young-woman-playing-dog-pet-beach-sunrise-sunset-girl-dog-having-fun-seasid-seaside-cute-neglected-stay-66480218.jpg
- src: https://thumbs.dreamstime.com/b/funny-picture-taken-sunrise-frozen-lake-perspective-rider-retro-bicycle-sunrise-personal-211066044.jpg
viewer : true
viewerOptions : {
title: false
# you can add more options here. refer https://github.com/fengyuanchen/viewerjs?tab=readme-ov-file#options
}
---
19 changes: 18 additions & 1 deletion layouts/_default/gallery.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{{ define "head" }}
<meta name="description" content="{{ .Title }} of {{ .Site.Title }}">
<!-- <link rel="stylesheet" href="{{ .Site.Params.staticPath }}/css/list.css" media="all"> -->
{{ if .Params.viewer | default true }}
<link rel="stylesheet" href="{{ .Site.Params.staticPath }}/css/gallery.css">
<link rel="stylesheet" href="{{ .Site.Params.staticPath }}/viewer/viewer.min.css">
<script src="{{ .Site.Params.staticPath }}/viewer/viewer.min.js"></script>
{{ end }}

{{ end }}

{{ define "title" }}
Expand All @@ -19,11 +25,22 @@ <h6 class="text-center">{{ .Params.description | emojify }}</h6>
{{ range .Params.galleryImages }}
<div class="col-md-4 p-0 m-0">
<div class="card p-0 m-0 border-0">
<img class="w-100" height="280px" src="{{ .src }}">
<img class="w-100 {{if .Params.viewer | default true}}viewer-enabled-image{{end}}" height="280px" src="{{ .src }}">
</div>
</div>
{{ end }}
</div>
</div>
</div>

{{ if .Params.viewer | default true }}
<script>
document.addEventListener('DOMContentLoaded', function() {
var viewer = new Viewer(document.getElementById('list-page'), {
...{{ .Params.viewerOptions }}
});
});
</script>
{{ end }}

{{ end }}
3 changes: 3 additions & 0 deletions static/css/gallery.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.viewer-enabled-image {
cursor: zoom-in;
}
9 changes: 9 additions & 0 deletions static/viewer/viewer.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions static/viewer/viewer.min.js

Large diffs are not rendered by default.

0 comments on commit 236b319

Please sign in to comment.