New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
output gallery data to data file instead of content #24
Comments
Hi @szac, thanks for the suggestion! I see the benefit of using a gallery in a blog post, so I'm open to adding this feature. Do you have any idea what kind of data would be needed in the data file? My time is a bit limited at the moment so if you could provide a minimal working example of what you have in mind that would be a great help! |
Hello! Sorry I missed your response here. Here's what I was thinking for data file: {
"galleryItems":[
{
"item":{
"type":"img",
"thumbnail":{
"path":"/path/to/file",
"thumbHeight":"200",
"thumbWidth":"200"
},
"med":{
"path":"/path/to/file",
"medHeight":"400",
"medWidth":"450"
},
"large":{
"path":"/path/to/file",
"medHeight":"600",
"medWidth":"1000"
}
}
},
{
"item":{
"type":"img",
"thumbnail":{
"path":"/path/to/file",
"thumbHeight":"200",
"thumbWidth":"200"
},
"med":{
"path":"/path/to/file",
"medHeight":"400",
"medWidth":"450"
},
"large":{
"path":"/path/to/file",
"medHeight":"600",
"medWidth":"1000"
}
}
}
],
"galleryName":"My Awesome Gallery"
} Here's an example of a content post that could use a shortcode to pull multiple galleries into one post +++
slug = ""
tags = []
categories = []
draft = true
excerpt = " "
title = "A post with two galleries"
date = "2017-11-26T07:47:50-06:00"
+++
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
{{< gallery galleryName="My Awesome Gallery" dir="/images/blog/my-awesome-gallery/" >}}
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
{{< gallery galleryName="A second Gallery in this post" dir="/images/blog/my-second-gallery/" >}}
Here's an example of how the shortcode could work: {{$dir := .Get "dir"}}
{{ $galleryName := .Get "galleryName" }}
{{ $data := .Get "data_file" }} #maybe this generated from the directory name instead?
<h3>{{ $galleryName }}</h3>
<div class="grid">
<div class="grid-sizer"></div>
{{ with (index .Page.Site.Data.galleries $data) }}
{{range .galleryItems }}
<div class="grid-item">
<span class="gallery-image">
<a href="{{ .item.large }}"><img src="{{ .item.thumbnail }}" /></a>
</span>
</div>
{{ end }}
{{ end }}
</div> |
@szac I'm still working on updating the documentation and the shortcodes, but the main functionality is now in the data_file branch |
Great! I'll install, test and report back. You're awesome @GjjvdBurg! |
Will this feature be in the master branch soon? |
@fabsmusicjunkie thanks for asking! It's not a big priority for me at the moment, but if you (or anyone else reading this) wants to put together a PR I'm happy to incorporate it. I think the main thing that still needs to happen is documentation and testing. |
Great job with this. I'd be interested in everything here except outputting the image galleries to their content files. By outputting the
hps udpate
result to a hugo data file I'd be free to pipe that data through a shortcode that I could embed in the body of any content file (like a blog post) and use my own HTML/UI.I'm currently using a go function to get the filenames from a directory I specify and looping over them. I'll probably try to do the same with your tool but point to the output directories and files generated.
The text was updated successfully, but these errors were encountered: