5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 10:16:22 +00:00

Merge branch 'issue-7537' into 17.3.alpine.panel.sutty.nl

This commit is contained in:
f 2023-10-20 13:11:41 -03:00
commit 5d406081a3
No known key found for this signature in database
5 changed files with 13 additions and 9 deletions

View file

@ -5,7 +5,7 @@ class MetadataOrder < MetadataTemplate
# El valor según la posición del post en la relación ordenada por
# fecha, a fecha más alta, posición más alta
def default_value
super || (site.indexed_posts(locale: locale).first.order + 1)
super || ((site.indexed_posts.where(locale: locale).first&.order || 0) + 1)
end
def save

View file

@ -34,14 +34,14 @@ class MetadataRelatedPosts < MetadataArray
#
# @return [IndexedPost::ActiveRecord_AssociationRelation]
def posts
site.indexed_posts.where(locale: locale).where.not(post_id: post.uuid.value).where(**filter)
site.indexed_posts.where(locale: locale).where.not(post_id: post.uuid.value).where(filter)
end
# Encuentra el filtro desde el esquema del atributo
#
# @return [Hash]
# @return [Hash,nil]
def filter
layout.metadata.dig(name, 'filter')&.to_h&.symbolize_keys || {}
layout.metadata.dig(name, 'filter')&.to_h&.symbolize_keys
end
def sanitize(uuid)

View file

@ -51,7 +51,7 @@ class Post
indexable_attributes.select do |attr|
self[attr].front_matter?
end.each do |attr|
ifm[attr] = self[attr].indexable_values
ifm[attr] = self[attr].try(:indexable_values)
end
end
end

View file

@ -16,7 +16,12 @@ class Site
def index_posts!
Site.transaction do
docs.each(&:index!)
jekyll.read
jekyll.documents.each do |doc|
doc.read!
Post.new(document: doc, site: self, layout: layouts[doc['layout'].to_sym]).index!
end
update(last_indexed_commit: repository.head_commit.oid)
end

View file

@ -2,10 +2,9 @@
%th= post_label_t(attribute, post: post)
%td
%ul{ dir: dir, lang: locale }
- metadata.value.each do |v|
- p = site.indexed_posts(locale: post.lang.value).find_by(post_id: v)&.post
- site.indexed_posts.where(locale: post.lang.value, post_id: metadata.value).find_each do |p|
-#
XXX: Ignorar todos los posts no encontrados (ej: fueron
borrados o el uuid cambió)
- next unless p
%li= link_to p.title.value, site_post_path(site, p.id)
%li= link_to p.title, site_post_path(site, p.path)