Skip to content
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

Files relative to source file #10

Open
chuyskywalker opened this issue Dec 20, 2015 · 5 comments
Open

Files relative to source file #10

chuyskywalker opened this issue Dec 20, 2015 · 5 comments

Comments

@chuyskywalker
Copy link

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!

@balupton
Copy link
Member

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

@balupton
Copy link
Member

Try this in your config:

plugins:
    associatedfiles:
        associatedFilesPath: false
        useRelativeBase: true

@balupton
Copy link
Member

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

@chuyskywalker
Copy link
Author

Alright, I'll give these a try. Thanks!

@chuyskywalker
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants