From 82d6657ae8658584c714cd0f5afed5195d41b65d Mon Sep 17 00:00:00 2001 From: Jeff Kolesky Date: Wed, 3 Aug 2016 15:08:26 -0700 Subject: [PATCH 1/3] Adds ability to link to all files Fixes request made in #4624 and bug found in #5182 --- lib/jekyll/tags/link.rb | 4 ++-- test/source/info.md | 7 +++++++ test/test_tags.rb | 31 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/source/info.md diff --git a/lib/jekyll/tags/link.rb b/lib/jekyll/tags/link.rb index 6ffd4726..03e2e52b 100644 --- a/lib/jekyll/tags/link.rb +++ b/lib/jekyll/tags/link.rb @@ -16,8 +16,8 @@ module Jekyll def render(context) site = context.registers[:site] - site.docs_to_write.each do |document| - return document.url if document.relative_path == @relative_path + site.each_site_file do |item| + return item.url if item.relative_path == @relative_path end raise ArgumentError, < [Jekyll::Filters], :registers => { :site => site } } @converter = site.converters.find { |c| c.class == converter_class } @@ -627,6 +628,36 @@ CONTENT end end + context "simple page with linking to a page" do + setup do + content = < source_dir, + "destination" => dest_dir, + "read_all" => true + }) + end + + should "not cause an error" do + refute_match(%r!markdown\-html\-error!, @result) + end + + should "have the URL to the \"contacts\" item" do + assert_match(%r!/contacts\.html!, @result) + end + + should "have the URL to the \"info\" item" do + assert_match(%r!/info\.html!, @result) + end + end + context "simple page with linking" do setup do content = < Date: Thu, 4 Aug 2016 19:40:14 -0700 Subject: [PATCH 2/3] Fixes tests to account for new info.md file --- test/test_filters.rb | 2 +- test/test_site.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_filters.rb b/test/test_filters.rb index 1f4a3889..b5f0a395 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -475,7 +475,7 @@ class TestFilters < JekyllUnitTest g["items"].is_a?(Array), "The list of grouped items for '' is not an Array." ) - assert_equal 13, g["items"].size + assert_equal 14, g["items"].size end end end diff --git a/test/test_site.rb b/test/test_site.rb index f09d94b9..4b4873ed 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -191,6 +191,7 @@ class TestSite < JekyllUnitTest humans.txt index.html index.html + info.md main.scss main.scss properties.html From e0ce4a00f80535d79f62fd0196fabfe8c445bef5 Mon Sep 17 00:00:00 2001 From: Jeff Kolesky Date: Thu, 4 Aug 2016 20:03:01 -0700 Subject: [PATCH 3/3] Fixes `link` tag to work with static files --- lib/jekyll/tags/link.rb | 2 ++ test/test_tags.rb | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/tags/link.rb b/lib/jekyll/tags/link.rb index 03e2e52b..a076c417 100644 --- a/lib/jekyll/tags/link.rb +++ b/lib/jekyll/tags/link.rb @@ -18,6 +18,8 @@ module Jekyll site.each_site_file do |item| return item.url if item.relative_path == @relative_path + # This takes care of the case for static files that have a leading / + return item.url if item.relative_path == "/#{@relative_path}" end raise ArgumentError, < source_dir, - "destination" => dest_dir, - "read_all" => true + "source" => source_dir, + "destination" => dest_dir, + "read_all" => true }) end @@ -656,6 +657,10 @@ CONTENT should "have the URL to the \"info\" item" do assert_match(%r!/info\.html!, @result) end + + should "have the URL to the \"screen.css\" item" do + assert_match(%r!/css/screen\.css!, @result) + end end context "simple page with linking" do