aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/lib/nuldoc/components/post_page_entry.rb
blob: 623c2be6e8121de2b47d8ffd3e744e318ffb6b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Nuldoc
  module Components
    class PostPageEntry
      extend DOM::HTML

      def self.render(post:, config:)
        published = Revision.date_to_string(GeneratorUtils.published_date(post))
        updated = Revision.date_to_string(GeneratorUtils.updated_date(post))
        has_updates = GeneratorUtils.any_updates?(post)

        article(class: 'post-entry') do
          a(href: post.href) do
            header(class: 'entry-header') { h2 { text post.title } }
            section(class: 'entry-content') { p { text post.description } }
            footer(class: 'entry-footer') do
              time(datetime: published) { text published }
              text ' 投稿'
              if has_updates
                text '、'
                time(datetime: updated) { text updated }
                text ' 更新'
              end
              TagList.render(tags: post.tags, config: config) if post.tags.length.positive?
            end
          end
        end
      end
    end
  end
end