Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent loading all GH data on reset #245

Merged
merged 5 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/jekyll-github-metadata/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def owner_public_repositories
:accept => "application/vnd.github.mercy-preview+json",
}
memoize_value :@owner_public_repositories, Value.new("owner_public_repositories", proc do |c|
c.list_repos(owner, options).map do |r|
repos = c.list_repos(owner, options) || []
repos.map do |r|
r[:releases] = Value.new("owner_public_repositories_releases", proc { c.releases(r[:full_name]) })
r[:contributors] = Value.new("owner_public_repositories_contributors", proc { c.contributors(r[:full_name]) })
r
Expand Down
15 changes: 12 additions & 3 deletions lib/jekyll-github-metadata/site_github_munger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class << self

def initialize(site)
Jekyll::GitHubMetadata.site = site
@original_config = site.config["github"]
end

def munge!
Expand All @@ -28,16 +29,20 @@ def inject_metadata!(payload)
payload.site["github"] = github_namespace
end

def uninject_metadata!(payload)
payload.site["github"] = @original_config
end

private

def github_namespace
case site.config["github"]
case @original_config
when nil
drop
when Hash
Jekyll::Utils.deep_merge_hashes(drop, site.config["github"])
drop.merge(@original_config)
else
site.config["github"]
@original_config
end
end

Expand Down Expand Up @@ -94,5 +99,9 @@ def should_warn_about_site_name?
Jekyll::Hooks.register :site, :pre_render do |_site, payload|
SiteGitHubMunger.global_munger.inject_metadata!(payload)
end

Jekyll::Hooks.register :site, :post_render do |_site, payload|
SiteGitHubMunger.global_munger.uninject_metadata!(payload)
end
end
end