docpad subdirectory rendered into general directory

风格不统一 提交于 2019-12-11 13:13:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!