Sha256: b1e87b6aebf2a82e098999cf542ba98e6c271a38085c7a3bd2796cc55307a509

Contents?: true

Size: 968 Bytes

Versions: 22

Compression:

Stored size: 968 Bytes

Contents

# (c) Copyright 2020 Ribose Inc.
#

module Jekyll
  module Geolexica
    module Hooks
      module_function

      def register_all_hooks
        hook :after_init, :site, :initialize_glossary
        hook :post_read, :site, :load_glossary
        hook :pre_render, :documents, :expose_glossary
        hook :pre_render, :pages, :expose_glossary
      end

      # Adds Jekyll::Site#glossary method, and initializes an empty glossary.
      def initialize_glossary(site)
        site.class.attr_reader :glossary
        site.instance_variable_set "@glossary", Glossary.new(site)
      end

      # Loads concept data into glossary.
      def load_glossary(site)
        site.glossary.load_glossary
      end

      def expose_glossary(page_or_document, liquid_drop)
        liquid_drop["glossary"] = page_or_document.site.glossary
      end

      def hook event, target, action
        Jekyll::Hooks.register target, event, &method(action)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
jekyll-geolexica-1.5.4 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.5.3 lib/jekyll/geolexica/hooks.rb