在我的wintersmith建造的网站上,我希望:
我将paginator.coffee复制到newspaginator.coffee中,调整它以返回' news'而不是'文章'以及其他一些调整,它工作正常。
然后我尝试重新添加原始分页器,并在config.json中添加一些参数:
"plugins": [
"./plugins/newspaginator.coffee",
"./plugins/paginator.coffee"
],
"newspaginator": {
"articles": "news",
"perPage": 10
},
"paginator": {
"articles": "articles",
"template": "blog.jade",
"first": "blog.html",
"filename": "blogpage/%d/index.html",
"perPage": 3
}
现在:我只获得第二个插件的HTML页面。如上所述,我得到blog.html但没有index.html。如果我颠倒了两个插件的顺序,我得到index.html但没有blog.html。
我如何做到这两点?
答案 0 :(得分:0)
paginator.coffee设置了一些wintersmith属性需要在你的" tweaks"或者一个插件将覆盖另一个插件的设置。这是我注意到的:
options = env.config.paginator or {}
...
env.helpers.getArticles = getArticles
...
env.registerGenerator 'paginator', (contents, callback) ->
以env.helpers.getArticles为例。在模板的某个地方,您可以调用类似env.helpers.getArticles(contents)的内容。这将是第二个插件被调用的方法,因为第二个插件会覆盖第一个插件的值。
您应该可以通过更改这三行来使其工作。这仍然是一个hacky解决方案,因为你正在复制代码(DRY Principles),但它可能是一个很好的快速解决方案,因为它看起来并不像paginator插件设置为多个工作。目录