docpad子目录呈现到常规目录中
如何将文件从docpad子目录呈现到常规目录中,docpad,Docpad,如何将文件从src/documents/posts/post1.html移动到out/post1.html,而不在out目录中显示子文件夹posts 我的文档中有一个子目录posts src/ documents/ index.html contact.html posts/ post1.html post2.html 我希望帖子在out/post1.htmlnotout/posts/pos
src/documents/posts/post1.html
移动到out/post1.html
,而不在out目录中显示子文件夹posts
我的文档中有一个子目录posts
src/
documents/
index.html
contact.html
posts/
post1.html
post2.html
我希望帖子在out/post1.html
notout/posts/post1.html
中 结果表明,您可以将relativePath
属性设置为您想要的任何值
@getCollection("html").findAllLive(..).on 'add', (document) ->
newRelativePath = document.get('relativePath').replace('posts/','')
document.set('relativePath', newRelativePath)
重要注意事项:
如果使用包含相对路径
的选择器的findAllLive
,然后更改相对路径
,文档将从集合中删除。或者,您可以设置另一个标志并使用它查找
@getCollection("html").findAllLive({$or:{relativeOutDirPath:'posts', isPost: true}}).on 'add', (document) ->
document.set('relativePath', newRelativePath)
.setMeta({isPost: true})
很好地解决了这个问题。:)一旦StackOverflow允许,不要忘记接受这个答案。;)我需要从out目录或document目录获取所有文件的集合。我尝试了@getCollection(“html”).findAllLive({relativeOutDirPath:'/'},[{order:1}]),但没有成功