From 14e5d00555eb7567bb8ff1827288979c000d725a Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Tue, 30 Apr 2019 18:33:48 +0530 Subject: [PATCH] Fix broken include_relative usage in excerpt (#7633) Merge pull request 7633 --- features/include_relative_tag.feature | 19 +++++++++++++++++++ lib/jekyll/tags/include.rb | 1 + 2 files changed, 20 insertions(+) diff --git a/features/include_relative_tag.feature b/features/include_relative_tag.feature index 80c0ef59..9cbdcf12 100644 --- a/features/include_relative_tag.feature +++ b/features/include_relative_tag.feature @@ -29,6 +29,25 @@ Feature: include_relative Tag And the _site directory should exist And I should see "Welcome back Dear Reader!" in "_site/2018/09/02/star-wars.html" + Scenario: Include a nested file relative to a post as an excerpt + Given I have a _posts directory + And I have a _posts/snippets directory + And I have a _posts/snippets/welcome_para directory + And I have a "_posts/2018-09-02-star-wars.md" file with content: + """ + {% include_relative snippets/welcome_para.md %} + + Hello World + """ + And I have an "_posts/snippets/welcome_para.md" file that contains "{% include_relative snippets/welcome_para/greeting.md %} Dear Reader!" + And I have an "_posts/snippets/welcome_para/greeting.md" file that contains "Welcome back" + And I have an "index.md" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "Welcome back Dear Reader!" in "_site/2018/09/02/star-wars.html" + And I should see "Welcome back Dear Reader!" in "_site/index.html" + Scenario: Include a nested file relative to a page at root Given I have a snippets directory And I have a snippets/welcome_para directory diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 510bd0d0..d81dd8de 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -209,6 +209,7 @@ module Jekyll else File.join(site.config["collections_dir"], page_payload["path"]) end + resource_path.sub!(%r!/#excerpt\z!, "") site.in_source_dir File.dirname(resource_path) end end