8000 Backport #8756 for v4.2.x: Respect collections_dir config within include tag by ashmaroli · Pull Request #8794 · jekyll/jekyll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Backport #8756 for v4.2.x: Respect collections_dir config within include tag #8794

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

Merged
merged 2 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions features/incremental_rebuild.feature
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ Feature: Incremental rebuild
And the _site directory should exist
And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/index.html"

Scenario: Rebuild when a dependency of document in custom collection_dir is changed
Given I have a _includes directory
And I have a configuration file with "collections_dir" set to "collections"
And I have a collections/_posts directory
And I have the following post within the "collections" directory:
| title | date | layout | content |
| Wargames | 2009-03-27 | default | Basic Site with include tag: {% include about.html %} |
And I have an "_includes/about.html" file that contains "Generated by Jekyll"
When I run jekyll build -I
Then I should get a zero exit status
And the _site directory should exist
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/2009/03/27/wargames.html"
When I wait 1 second
Then I have an "_includes/about.html" file that contains "Regenerated by Jekyll"
When I run jekyll build -I
Then I should get a zero exit status
And the _site directory should exist
And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/2009/03/27/wargames.html"

Scenario: A themed-site and incremental regeneration
Given I have a configuration file with "theme" set to "test-theme"
And I have an "index.md" page that contains "Themed site"
Expand Down
15 changes: 10 additions & 5 deletions lib/jekyll/tags/include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,17 @@ def realpath_prefixed_with?(path, dir)
end

def add_include_to_dependency(inclusion, context)
return unless context.registers[:page]&.key?("path")
page = context.registers[:page]
return unless page&.key?("path")

absolute_path = \
if page["collection"]
@site.in_source_dir(@site.config["collections_dir"], page["path"])
else
@site.in_source_dir(page["path"])
end

@site.regenerator.add_dependency(
@site.in_source_dir(context.registers[:page]["path"]),
inclusion.path
)
@site.regenerator.add_dependency(absolute_path, inclusion.path)
end
end

Expand Down
0