docpad子目录呈现到常规目录 [英] docpad subdirectory rendered into general directory
问题描述
如何将文件从src/documents/posts/post1.html
移到out/post1.html
,而子文件夹posts
不在out目录中?
How to move files from src/documents/posts/post1.html
to out/post1.html
without the subfolder posts
appearing in the out directory?
我的documents
src/
documents/
index.html
contact.html
posts/
post1.html
post2.html
我希望帖子位于out/post1.html
中而不是out/posts/post1.html
中.
And I want the posts to be in out/post1.html
not out/posts/post1.html
.
推荐答案
原来,您可以将relativePath
属性设置为所需的任何内容
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)
重要提示:
如果使用findAllLive
,而选择器包含relativePath
,然后更改relativePath
,则文档将从集合中删除.另外,您可以设置另一个标志并将其用于查找.
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})
这篇关于docpad子目录呈现到常规目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!