{"action":"closed","issue":{"url":"https://api.github.com/repos/spress/Spress/issues/63","repository_url":"https://api.github.com/repos/spress/Spress","labels_url":"https://api.github.com/repos/spress/Spress/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/spress/Spress/issues/63/comments","events_url":"https://api.github.com/repos/spress/Spress/issues/63/events","html_url":"https://github.com/spress/Spress/issues/63","id":127109179,"number":63,"title":"Items in collections should be ordered","user":{"login":"jjk-jacky","id":1540519,"avatar_url":"https://avatars.githubusercontent.com/u/1540519?v=3","gravatar_id":"","url":"https://api.github.com/users/jjk-jacky","html_url":"https://github.com/jjk-jacky","followers_url":"https://api.github.com/users/jjk-jacky/followers","following_url":"https://api.github.com/users/jjk-jacky/following{/other_user}","gists_url":"https://api.github.com/users/jjk-jacky/gists{/gist_id}","starred_url":"https://api.github.com/users/jjk-jacky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjk-jacky/subscriptions","organizations_url":"https://api.github.com/users/jjk-jacky/orgs","repos_url":"https://api.github.com/users/jjk-jacky/repos","events_url":"https://api.github.com/users/jjk-jacky/events{/privacy}","received_events_url":"https://api.github.com/users/jjk-jacky/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-01-17T17:14:27Z","updated_at":"2016-03-26T20:28:25Z","closed_at":"2016-03-26T20:28:25Z","body":"Currently items in a collection aren't in any given order, which basically means\r\nthey're \"useless\" since they're pretty much in a random order. For example, if\r\none tries to loop over them to make an RSS feed, via e.g:\r\n\r\n    for post in site.posts\r\n\r\nIt won't give proper results, since again there's no order. I'm not really\r\nfamiliar with Spress codebase so I'm not sure on the \"how\" but I believe this\r\ncould be addressed in ContentManager->process(), after looping over $items and\r\nbefore looping over $itemsGenerator, it should be possible to loop over\r\n$this->itemsByCollection, and then apply a default order which could be set from\r\nconfig, e.g:\r\n\r\n    collections:\r\n        posts:\r\n            sort_by: date\r\n        projects:\r\n            sort_by: title\r\n            sort_type: ascending\r\n\r\nOf course it also means this default sort order will be of use in generators,\r\nthough it'll still be possible to define a custom sort order alongside a\r\ngenerator, as is the case today.\r\n\r\n\r\nAdditionally, I'd also like it a lot if, after this default sorting, all items\r\ncould get attributes referring to the previous & next items in the collection\r\n(as per this default sort order). That way, when generating the page for one item\r\nin a collection, it'd be possible to have links to the previous and/or next item\r\nin said collection.\r\n\r\nThis might not be as necessary to make items usable, but it'd be nice to have;\r\nand I won't lie, I'm needing this to convert a site from jekyll to Spress, so\r\nyeah."}}