5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-02 13:26:07 +00:00

usar el lenguaje por defecto en posts_for tambien

This commit is contained in:
f 2018-05-14 14:17:13 -03:00
parent 8d70037aee
commit 47e149b1c9
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7

View file

@ -99,6 +99,10 @@ class Site
@collections
end
def collections_names
@jekyll.config['collections'].keys
end
# Los posts de este sitio, si el sitio está traducido, trae los posts
# del idioma actual, porque _posts va a estar vacío
def posts
@ -114,11 +118,10 @@ class Site
#
# Devuelve nil si la colección no existe
def posts_for(collection)
return unless @jekyll.config['collections'].key? collection
return unless collections_names.include? collection
# Si pedimos 'posts' pero estamos en un sitio traducido, traemos el
# idioma actual
collection = I18n.locale.to_s if collection == 'posts' && i18n?
collection = default_lang if collection == 'posts' && i18n?
_collection = @collections[collection]
return _collection if _collection
@ -149,6 +152,9 @@ class Site
def everything_of(attr, lang: nil)
collection = lang || 'posts'
return [] unless collections_names.include? collection
posts_for(collection).map do |p|
p.get_front_matter attr
end.flatten.uniq