Replace nested conditional with guard clauses (#8294)
Merge pull request 8294
This commit is contained in:
parent
119c490ad2
commit
f5826eed3c
|
@ -14,5 +14,4 @@ Layout/SpaceAroundOperators:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/jekyll/commands/build.rb'
|
- 'lib/jekyll/commands/build.rb'
|
||||||
- 'lib/jekyll/site.rb'
|
- 'lib/jekyll/site.rb'
|
||||||
- 'lib/jekyll/tags/include.rb'
|
|
||||||
- 'test/test_configuration.rb'
|
- 'test/test_configuration.rb'
|
||||||
|
|
|
@ -253,20 +253,18 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_path(context)
|
def page_path(context)
|
||||||
if context.registers[:page].nil?
|
page, site = context.registers.values_at(:page, :site)
|
||||||
context.registers[:site].source
|
return site.source unless page
|
||||||
else
|
|
||||||
site = context.registers[:site]
|
site.in_source_dir File.dirname(resource_path(page, site))
|
||||||
page_payload = context.registers[:page]
|
end
|
||||||
resource_path = \
|
|
||||||
if page_payload["collection"].nil?
|
private
|
||||||
page_payload["path"]
|
|
||||||
else
|
def resource_path(page, site)
|
||||||
File.join(site.config["collections_dir"], page_payload["path"])
|
path = page["path"]
|
||||||
end
|
path = File.join(site.config["collections_dir"], path) if page["collection"]
|
||||||
resource_path.sub!(%r!/#excerpt\z!, "")
|
path.sub(%r!/#excerpt\z!, "")
|
||||||
site.in_source_dir File.dirname(resource_path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue