Files relative to source file
chuyskywalker opened this issue · 5 comments
I've toyed about with the options a number of ways, but can't seem to get this to scan for file relative to the document being rendered. I would like this structure to work:
documents/
subfolder/
pictures.html.eco
images/
image1.jpg
image2.jpg
So that I can keep my image files more closely related to the document they're about.
Is that possible now and I'm just missing it? Or is this a feature request?
Thanks!
Seems sensible. I'll be surprised if there wasn't a way to do this. I'm pretty queued up with stuff but perhaps try stack overflow with the docpad tag or our slack channel at slack.bevry.me and someone will be able to help
Try this in your config:
plugins:
associatedfiles:
associatedFilesPath: false
useRelativeBase: true
The plugin seems capable of doing it, just seems on whatever combination of config and setup will allow it. However, the plugin is super simple, so perhaps what could be easier until a new simpler plugin version can be released would be to replace the @getAssociatedFiles
call with @getFilesAtPath(@document.relativeBase + '-images', [name:1, date:-1])
which would allow:
documents/
my-post.html.eco
my-post-images/
image1.jpg
image2.jpg
Alright, I'll give these a try. Thanks!
I ended up using:
<% for file in @getFilesAtPath(@document.relativeOutDirPath + '/' + 'images', [name:1, date:-1]).toJSON(): %>
<p>
<img src="<%= file.url %>" title="<%= file.title or file.name %>" /><br />
<i><%= file.title or file.name %></i>
</p>
<% end %>
Thanks for getting me pointed in the right direction!