docpad子目录呈现到常规目录 [英] docpad subdirectory rendered into general directory

查看:64
本文介绍了docpad子目录呈现到常规目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将文件从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆