Skip to content

Commit

Permalink
Build: allow repeated rebuilding in Jekyll Preview mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
harding committed Jun 23, 2017
1 parent be6167d commit b9e114e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
24 changes: 13 additions & 11 deletions _plugins/contributors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ def contributors(repo, aliases)

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

Expand Down
20 changes: 11 additions & 9 deletions _plugins/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ def conferences

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

Expand Down

0 comments on commit b9e114e

Please sign in to comment.