Last active
July 9, 2019 13:14
-
-
Save sarmis/5ad90bd7624e2f1f3f2c14c93a751df8 to your computer and use it in GitHub Desktop.
Justified Image Gallery as Hugo shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- \layouts\shortcodes\foldergallery.html --> | |
<style> | |
div.gallery { | |
display: flex; | |
flex-wrap: wrap; | |
} | |
div.gallery a { | |
flex-grow: 1; | |
object-fit: cover; | |
margin: 2px; | |
display: flex; | |
} | |
div.gallery a img { | |
height: 200px; | |
object-fit: cover; | |
flex-grow: 1; | |
} | |
</style> | |
<div class="gallery"> | |
{{ $path := print "content\\" .Page.Dir (.Get "src") }} | |
{{ $url := print .Page.URL (.Get "src") }} | |
{{ range (readDir $path) }} | |
{{ $src := print $url "/" .Name }} | |
<a data-fancybox="gallery" href="{{ $src }}"> | |
<img src="{{ $src }}"> <br/> | |
</a> | |
{{ end }} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment