diff --git a/app/models/site.rb b/app/models/site.rb index 2a1d9b32..7c423498 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -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