Sha256: bc1599f3bc02dd327cf043b78294203d9631ca6f86c95fdbf55f2c6c4ccba388

Contents?: true

Size: 932 Bytes

Versions: 15

Compression:

Stored size: 932 Bytes

Contents

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

15 entries across 15 versions & 1 rubygems

Version Path
jekyll-geolexica-1.5.2 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.5.1 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.5.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.4.1 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.4.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.3.3 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.3.2 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.3.1 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.3.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.2.2 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.2.1 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.2.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.1.0 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.0.2 lib/jekyll/geolexica/hooks.rb
jekyll-geolexica-1.0.0 lib/jekyll/geolexica/hooks.rb