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.9.1 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.9.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.15 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.14 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.13 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.12 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.11 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.10 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.9 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.8 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.7 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.6 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.5 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.4 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.3 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.2 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.1 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.8.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.7.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.6.0 lib/jekyll/geolexica/hooks.rb