File: hook.rb

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

module Jekyll
  module LastModifiedAt
    module Hook
      class << self
        def add_determinator_proc
          proc { |item|
            format = item.site.config.dig("last-modified-at", "date-format")
            item.data["last_modified_at"] = Determinator.new(
              item.site.source,
              item.path,
              format,
            )
          }
        end
      end

      Jekyll::Hooks.register(:posts, :post_init, &Hook.add_determinator_proc)
      Jekyll::Hooks.register(:pages, :post_init, &Hook.add_determinator_proc)
      Jekyll::Hooks.register(:documents, :post_init, &Hook.add_determinator_proc)
    end
  end
end