2017-01-30 11 views
1

私は古いサイトをgrunt-assembleからassembleまで(gulp)に移行しようとしています。最新の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'] 
     }] 
    } 
    } 
}); 

答えて

0

あなたはあなたの目標を達成するためにhandlebars-helpersから{{items}} helper from assemble-helpersの組み合わせとwithSortヘルパーを使用することができます。

{{#withSort "data.posted" (items "posts") reverse=true}} 
    {{this.data.title}} 
{{/withSort}} 

これはまた、あなたが「ポスト」ビューのコレクションを作成しました、あなたのをロードしていることを前提としてい「投稿」:

// 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'); 
関連する問題