Sha256: 481a092bce570ab2e84b8f6f06b9c87c36b61afd4f6a84747804734afa246bd1
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'json' require_relative 'configuration' # Register Hooks, if livereload is enabled module Jekyll module Livereload module Build include Livereload::Configuration def process(opts) opts = load_config_options(opts) if opts['livereload'] Jekyll::Hooks.register(:site, :post_render) do |site| regenerator = Jekyll::Regenerator.new(site) Livereload.pages = site.pages.select do |p| regenerator.regenerate?(p) end end Jekyll::Hooks.register([:pages, :documents], :post_render) do |doc| doc.output.sub!(/<head>(.*)<\/head>/m, "<head>\\1#{reload_script(opts)}</head>") end Jekyll::Hooks.register :site, :post_write do Livereload.reactor.reload() unless Livereload.reactor.nil? end end super opts end private def reload_script(opts) "<script src=\"http://#{opts['host']}:#{opts['reload_port']}/livereload.js\"></script>" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-livereload-0.1.1.1 | lib/jekyll-livereload/build.rb |