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
.
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})