helpers.js 539 B

12345678910111213141516171819202122
  1. hexo.extend.helper.register('order_pages', function(pages){
  2. var page_list = [];
  3. pages.forEach(page => {
  4. page_list.push(page);
  5. });
  6. page_list.sort(function(a,b){
  7. return new Date(b.date) - new Date(a.date);
  8. });
  9. return page_list;
  10. });
  11. hexo.extend.helper.register('get_page', function(pages, id){
  12. var result = undefined;
  13. pages.forEach(page => {
  14. if(page.id != undefined){
  15. if(page.id == id) {
  16. result = page;
  17. }
  18. }
  19. });
  20. return result;
  21. });