class Pages::Post < ::Phlex::HTML
  def initialize(post)
    @slug = post[:slug]
    @post = post
  end
  def view_template
    meta = @post[:data].front_matter
    render ::Pages::Layout.new({title: meta['title']}) {
      article(class: 'prose prose-lg m-auto') {
        h1 { meta['title'] }
        if meta['published_on']
          time(datetime: meta['published_on']) { meta['published_on'] }
        else
          div(class: 'flex flex-row gap-2 -my-5 items-center') {
            raw safe(::Util::Heroicons.pencil_square('size-4 block'))
            p { 'Draft' }
          }
        end

        hr

        render ::Phlex::Markdown.new(@post[:data].content)
      }
    }
  end
end
