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
not
out/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}]),但没有成功