From ca9989ae29a956e7bb5bf7fe84920cafb41d692c Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 13 Apr 2020 13:15:33 +0530 Subject: [PATCH] Backport #7908 for v4.0.x Add static file's basename to its url_placeholder This backports be70c3e to 4.0-stable --- features/collections.feature | 14 ++++++++++++++ lib/jekyll/static_file.rb | 2 +- test/source/_methods/extensionless_static_file | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/source/_methods/extensionless_static_file diff --git a/features/collections.feature b/features/collections.feature index 84677831d58..5924e7e6bc6 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -610,3 +610,17 @@ Feature: Collections And I should see "Thanksgiving Black Friday" in "_site/index.html" And I should see "Happy Thanksgiving" in "_site/thanksgiving/2015-11-26-thanksgiving.html" And I should see "Black Friday" in "_site/thanksgiving/black-friday.html" + + Scenario: Rendered collection with custom permalinks and static file contents + Given I have fixture collections + And I have a "_config.yml" file with content: + """ + collections: + methods: + output: true + permalink: /:collection/:name + """ + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "I have no front matter." in "_site/methods/extensionless_static_file" diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 0dce964049e..18bba13b10f 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -126,7 +126,7 @@ def placeholders :collection => @collection.label, :path => cleaned_relative_path, :output_ext => "", - :name => "", + :name => basename, :title => "", } end diff --git a/test/source/_methods/extensionless_static_file b/test/source/_methods/extensionless_static_file new file mode 100644 index 00000000000..b050c592890 --- /dev/null +++ b/test/source/_methods/extensionless_static_file @@ -0,0 +1 @@ +I have no front matter.