Merge pull request #4703 from jekyll/after_init_hook
Merge pull request 4703
This commit is contained in:
commit
afa89d68f8
|
@ -12,6 +12,7 @@ module Jekyll
|
||||||
# initial empty hooks
|
# initial empty hooks
|
||||||
@registry = {
|
@registry = {
|
||||||
:site => {
|
:site => {
|
||||||
|
:after_init => [],
|
||||||
:after_reset => [],
|
:after_reset => [],
|
||||||
:post_read => [],
|
:post_read => [],
|
||||||
:pre_render => [],
|
:pre_render => [],
|
||||||
|
|
|
@ -17,6 +17,31 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# config - A Hash containing site configuration details.
|
# config - A Hash containing site configuration details.
|
||||||
def initialize(config)
|
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
|
@config = config.clone
|
||||||
|
|
||||||
%w(safe lsi highlighter baseurl exclude include future unpublished
|
%w(safe lsi highlighter baseurl exclude include future unpublished
|
||||||
|
@ -24,17 +49,6 @@ module Jekyll
|
||||||
self.send("#{opt}=", config[opt])
|
self.send("#{opt}=", config[opt])
|
||||||
end
|
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.plugin_manager = Jekyll::PluginManager.new(self)
|
||||||
self.plugins = plugin_manager.plugins_path
|
self.plugins = plugin_manager.plugins_path
|
||||||
|
|
||||||
|
@ -43,10 +57,7 @@ module Jekyll
|
||||||
|
|
||||||
self.permalink_style = config['permalink'].to_sym
|
self.permalink_style = config['permalink'].to_sym
|
||||||
|
|
||||||
Jekyll.sites << self
|
@config
|
||||||
|
|
||||||
reset
|
|
||||||
setup
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Read, process, and write this Site to output.
|
# Public: Read, process, and write this Site to output.
|
||||||
|
|
|
@ -516,6 +516,18 @@ The complete list of available hooks is below:
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p><code>:site</code></p>
|
<p><code>:site</code></p>
|
||||||
|
|
Loading…
Reference in New Issue