Merge pull request #4703 from jekyll/after_init_hook

Merge pull request 4703
This commit is contained in:
jekyllbot 2016-03-25 16:27:38 -07:00
commit afa89d68f8
3 changed files with 39 additions and 15 deletions

View File

@ -12,6 +12,7 @@ module Jekyll
# initial empty hooks
@registry = {
:site => {
:after_init => [],
:after_reset => [],
:post_read => [],
:pre_render => [],

View File

@ -17,6 +17,31 @@ module Jekyll
#
# config - A Hash containing site configuration details.
def initialize(config)
# Source and destination may not be changed after the site has been created.
@source = File.expand_path(config['source']).freeze
@dest = File.expand_path(config['destination']).freeze
self.config = config
@reader = Reader.new(self)
@regenerator = Regenerator.new(self)
@liquid_renderer = LiquidRenderer.new(self)
Jekyll.sites << self
Jekyll::Hooks.trigger :site, :after_init, self
reset
setup
end
# Public: Set the site's configuration. This handles side-effects caused by
# changing values in the configuration.
#
# config - a Jekyll::Configuration, containing the new configuration.
#
# Returns the new configuration.
def config=(config)
@config = config.clone
%w(safe lsi highlighter baseurl exclude include future unpublished
@ -24,17 +49,6 @@ module Jekyll
self.send("#{opt}=", config[opt])
end
# Source and destination may not be changed after the site has been created.
@source = File.expand_path(config['source']).freeze
@dest = File.expand_path(config['destination']).freeze
@reader = Jekyll::Reader.new(self)
# Initialize incremental regenerator
@regenerator = Regenerator.new(self)
@liquid_renderer = LiquidRenderer.new(self)
self.plugin_manager = Jekyll::PluginManager.new(self)
self.plugins = plugin_manager.plugins_path
@ -43,10 +57,7 @@ module Jekyll
self.permalink_style = config['permalink'].to_sym
Jekyll.sites << self
reset
setup
@config
end
# Public: Read, process, and write this Site to output.

View File

@ -516,6 +516,18 @@ The complete list of available hooks is below:
</tr>
</thead>
<tbody>
<tr>
<td>
<p><code>:site</code></p>
</td>
<td>
<p><code>:after_init</code></p>
</td>
<td>
<p>Just after the site initializes, but before setup & render. Good
for modifying the configuration of the site.</p>
</td>
</tr>
<tr>
<td>
<p><code>:site</code></p>