Module: Jekyll::Timeago

Extended by:
Timeago
Included in:
Timeago
Defined in:
lib/jekyll-timeago.rb,
lib/jekyll-timeago/core.rb,
lib/jekyll-timeago/version.rb,
lib/jekyll-timeago/jekyll_integration.rb

Defined Under Namespace

Modules: Core, Filter Classes: Tag

Constant Summary collapse

VERSION =
"0.13.1"
@@jekyll_initialized =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jekyll_config(context) ⇒ Object


5
6
7
# File 'lib/jekyll-timeago/jekyll_integration.rb', line 5

def self.jekyll_config(context)
  @@jekyll_config ||= context.registers[:site].config['jekyll_timeago'] || {}
end

.jekyll_page_data(context) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jekyll-timeago/jekyll_integration.rb', line 9

def self.jekyll_page_data(context)
  options = jekyll_config(context)
  locale = context['page']['locale']

  options[:locale] = locale if locale

  if !@@jekyll_initialized
    MiniI18n.configure do |config|
      if options['translations_path']
        path = context.registers[:site].source + options['translations_path']
        config.load_translations(path)
      end

      config.available_locales = options['available_locales']
      config.default_locale = options['default_locale']
      config.fallbacks = options['fallbacks']
    end

    @@jekyll_initialized = true
  end

  options
end

Instance Method Details

#timeago(from, to = Date.today, options = {}) ⇒ Object


13
14
15
# File 'lib/jekyll-timeago.rb', line 13

def timeago(from, to = Date.today, options = {})
  Core.timeago(from, to, options)
end