问题
How to move files from src/documents/posts/post1.html to out/post1.html without the subfolder posts appearing in the out directory?
I have a sub directory posts in my documents
src/
documents/
index.html
contact.html
posts/
post1.html
post2.html
And I want the posts to be in out/post1.html not out/posts/post1.html.
回答1:
Turns out you can set the relativePath property to whatever you want
@getCollection("html").findAllLive(..).on 'add', (document) ->
newRelativePath = document.get('relativePath').replace('posts/','')
document.set('relativePath', newRelativePath)
ImportantNote:
if you use a findAllLive whith a selector that includes the relativePath and then change the relativePath, the document will be removed from the collection. Alternatively you can set another flag and use it for finding.
@getCollection("html").findAllLive({$or:{relativeOutDirPath:'posts', isPost: true}}).on 'add', (document) ->
document.set('relativePath', newRelativePath)
.setMeta({isPost: true})
来源:https://stackoverflow.com/questions/18809753/docpad-subdirectory-rendered-into-general-directory