File: tag.rb

package info (click to toggle)
ruby-jekyll-last-modified-at 1.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 188 kB
  • sloc: ruby: 346; makefile: 4; sh: 3
file content (22 lines) | stat: -rw-r--r-- 651 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module Jekyll
  module LastModifiedAt
    class Tag < Liquid::Tag
      def initialize(tag_name, format, tokens)
        super
        @format = format.empty? ? nil : format.strip
      end

      def render(context)
        site = context.registers[:site]
        format = @format || site.config.dig('last-modified-at', 'date-format')
        article_file = context.environments.first['page']['path']
        Determinator.new(site.source, article_file, format)
                    .formatted_last_modified_date
      end
    end
  end
end

Liquid::Template.register_tag('last_modified_at', Jekyll::LastModifiedAt::Tag)