Build: allow repeated rebuilding in Jekyll Preview mode

The events and contributor plugins both monkey patched the `site`
object.  This worked fine when they were loaded once per site build, but
with Jekyll 3.0 automatic site rebuilding in preview and watch modes,
this applied the monkey patch recursively, causing the program to halt.

With this commit, the monkey patching should only occur once per run.
This commit is contained in:
David A. Harding 2017-06-07 12:56:37 -04:00
parent be6167d8fb
commit b9e114efe8
No known key found for this signature in database
GPG key ID: 4B29C30FF29EC4B7
2 changed files with 24 additions and 20 deletions

View file

@ -78,17 +78,19 @@ module Jekyll
def generate(site) def generate(site)
# Set site.contributors global variables for liquid/jekyll # Set site.contributors global variables for liquid/jekyll
class << site if ! site.respond_to?('corecontributors')
attr_accessor :corecontributors class << site
attr_accessor :sitecontributors attr_accessor :corecontributors
alias contrib_site_payload site_payload attr_accessor :sitecontributors
def site_payload alias contrib_site_payload site_payload
h = contrib_site_payload def site_payload
payload = h["site"] h = contrib_site_payload
payload["corecontributors"] = self.corecontributors payload = h["site"]
payload["sitecontributors"] = self.sitecontributors payload["corecontributors"] = self.corecontributors
h["site"] = payload payload["sitecontributors"] = self.sitecontributors
h h["site"] = payload
h
end
end end
end end

View file

@ -42,15 +42,17 @@ module Jekyll
def generate(site) def generate(site)
# Set site.meetups and site.conferences global variables for liquid/jekyll # Set site.meetups and site.conferences global variables for liquid/jekyll
class << site if ! site.respond_to?('conferences')
attr_accessor :conferences class << site
alias event_site_payload site_payload attr_accessor :meetups, :conferences
def site_payload alias event_site_payload site_payload
h = event_site_payload def site_payload
payload = h["site"] h = event_site_payload
payload["conferences"] = self.conferences payload = h["site"]
h["site"] = payload payload["conferences"] = self.conferences
h h["site"] = payload
h
end
end end
end end