我正在尝试将一个旧站点从grunt-assemble迁移到assemble (使用gulp)。
我已经设法找出了很多不同之处,但我真的不确定集合现在是如何工作的,以及如何创建一个帖子集合,然后对它们进行排序。
我在grunt-assemble中的旧配置是这样的:
grunt.initConfig({
assemble: {
posts: {
options: {
collections: [{
name: 'post',
sortby: 'posted',
sortorder: 'descending'
}],
permalinks: {
structure: ':url.html'
}
},
files: [{
cwd: './src/templates/pages/blog/',
dest: '<%= site.destination %>/blog',
expand: true,
src: ['**/*.hbs', '**/*.md']
}]
}
}
});如何将其转换为在最新版本的Assemble中工作?
发布于 2017-07-05 22:19:47
您可以组合使用来自handlebars-helpers的{{items}} helper from assemble-helpers和withSort助手来实现您的目标:
{{#withSort "data.posted" (items "posts") reverse=true}}
{{this.data.title}}
{{/withSort}}这也假设你已经创建了一个“post”视图集合,并且你正在将你的“post”加载到其中:
// create the "posts" view collection (usually done outside of a task)
app.create('posts');
// load markdown posts into the "posts" view collection (usually done in a "load" task
app.posts('path/to/posts/*.md');https://stackoverflow.com/questions/41933320
复制相似问题