Respect collections_dir config within include tag (#8756)
Merge pull request 8756
This commit is contained in:
		
							parent
							
								
									55b6972ea7
								
							
						
					
					
						commit
						aa9a4164d0
					
				|  | @ -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" | ||||
|  |  | |||
|  | @ -234,12 +234,18 @@ module Jekyll | |||
|       end | ||||
| 
 | ||||
|       def add_include_to_dependency(inclusion, context) | ||||
|         return unless context.registers[:page]&.key?("path") | ||||
|         page = context.registers[:page] | ||||
|         return unless page&.key?("path") | ||||
| 
 | ||||
|         @site.regenerator.add_dependency( | ||||
|           @site.in_source_dir(context.registers[:page]["path"]), | ||||
|           inclusion.path | ||||
|         ) | ||||
|         page_path = context.registers[:page]["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(absolute_path, inclusion.path) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue