-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes zippable extensions configurable in site config
- Loading branch information
Showing
5 changed files
with
87 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require "jekyll/gzip/version" | ||
require "jekyll/gzip/compressor" | ||
require "pathname" | ||
require 'jekyll/gzip/version' | ||
require 'jekyll/gzip/config' | ||
require 'jekyll/gzip/compressor' | ||
require 'pathname' | ||
|
||
module Jekyll | ||
module Gzip | ||
end | ||
end | ||
|
||
Jekyll::Hooks.register :site, :after_init do |site| | ||
config = site.config['gzip'] || {} | ||
site.config['gzip'] = Jekyll::Gzip::DEFAULT_CONFIG.merge(config) || [] | ||
puts site.config['gzip'] | ||
end | ||
|
||
Jekyll::Hooks.register :site, :post_write do |site| | ||
if Jekyll.env == "production" | ||
Jekyll::Gzip::Compressor.compress_site(site) | ||
end | ||
Jekyll::Gzip::Compressor.compress_site(site) if Jekyll.env == 'production' | ||
end | ||
|
||
begin | ||
require "jekyll-assets" | ||
require 'jekyll-assets' | ||
|
||
Jekyll::Assets::Hook.register :env, :after_write do |env| | ||
if Jekyll.env == "production" | ||
path = Pathname.new("#{env.jekyll.config["destination"]}#{env.prefix_url}") | ||
Jekyll::Gzip::Compressor.compress_directory(path) | ||
if Jekyll.env == 'production' | ||
path = Pathname.new("#{env.jekyll.config['destination']}#{env.prefix_url}") | ||
Jekyll::Gzip::Compressor.compress_directory(path, env.jekyll) | ||
end | ||
end | ||
rescue LoadError | ||
# The Jekyll site doesn't use Jekyll::Assets, so no need to compress those | ||
# files. | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Jekyll | ||
module Gzip | ||
DEFAULT_CONFIG = { | ||
'extensions' => [ | ||
'.html', | ||
'.css', | ||
'.js', | ||
'.txt', | ||
'.ttf', | ||
'.atom', | ||
'.stl', | ||
'.xml', | ||
'.svg', | ||
'.eot' | ||
] | ||
}.freeze | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters