From e87643acd4e0b57d81edecd39d9c592599e1c2ed Mon Sep 17 00:00:00 2001 From: f Date: Thu, 17 Oct 2019 16:18:38 -0300 Subject: [PATCH] =?UTF-8?q?usar=20el=20orden=20cronol=C3=B3gico=20inverso?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site.rb | 6 +++++- test/integration/editor_test.rb | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index bb95fdb1..eb378085 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -173,9 +173,13 @@ class Site < ApplicationRecord @posts[lang] = PostRelation.new site: self + # Jekyll lee los documentos en orden cronológico pero los invierte + # durante la renderización. Usamos el orden cronológico inverso por + # defecto para mostrar los artículos más nuevos primero. + docs = collections[lang.to_s].try(:docs).try(:sort) { |a, b| b <=> a } # No fallar si no existe colección para este idioma # XXX: queremos fallar silenciosamente? - (collections[lang.to_s].try(:docs) || []).each do |doc| + (docs || []).each do |doc| layout = layouts[doc.data['layout'].to_sym] @posts[lang].build(document: doc, layout: layout, lang: lang) diff --git a/test/integration/editor_test.rb b/test/integration/editor_test.rb index 95f42c93..2b64eb06 100644 --- a/test/integration/editor_test.rb +++ b/test/integration/editor_test.rb @@ -48,7 +48,7 @@ class EditorTest < ActionDispatch::IntegrationTest } } - @post = @site.posts.last + @post = @site.posts.first assert_equal md_content.strip, @post.content.value end @@ -67,7 +67,7 @@ class EditorTest < ActionDispatch::IntegrationTest } } - @post = @site.posts.last + @post = @site.posts.first assert_equal trix_md.strip, @post.content.value end