usar el lenguaje por defecto en posts_for tambien
This commit is contained in:
parent
8d70037aee
commit
47e149b1c9
1 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue