Skip to content

Commit

Permalink
Merge pull request #5199 from jeffkole/adds-linking-to-all-files
Browse files Browse the repository at this point in the history
Merge pull request 5199
  • Loading branch information
jekyllbot committed Sep 13, 2016
2 parents 55de780 + e0ce4a0 commit 4888b84
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/jekyll/tags/link.rb
Expand Up @@ -16,8 +16,10 @@ def initialize(tag_name, relative_path, tokens)
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
# 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, <<eos
Expand Down
7 changes: 7 additions & 0 deletions test/source/info.md
@@ -0,0 +1,7 @@
---
title: Information
---

# Information

Very important information is here
2 changes: 1 addition & 1 deletion test/test_filters.rb
Expand Up @@ -475,7 +475,7 @@ def to_liquid
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
Expand Down
1 change: 1 addition & 0 deletions test/test_site.rb
Expand Up @@ -191,6 +191,7 @@ def generate(site)
humans.txt
index.html
index.html
info.md
main.scss
main.scss
properties.html
Expand Down
36 changes: 36 additions & 0 deletions test/test_tags.rb
Expand Up @@ -12,6 +12,7 @@ def create_post(content, override = {}, converter_class = Jekyll::Converters::Ma

site.posts.docs.concat(PostReader.new(site).read_posts("")) if override["read_posts"]
CollectionReader.new(site).read if override["read_collections"]
site.read if override["read_all"]

info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
@converter = site.converters.find { |c| c.class == converter_class }
Expand Down Expand Up @@ -627,6 +628,41 @@ def highlight_block_with_opts(options_string)
end
end

context "simple page with linking to a page" do
setup do
content = <<CONTENT
---
title: linking
---
{% link contacts.html %}
{% link info.md %}
{% link /css/screen.css %}
CONTENT
create_post(content, {
"source" => 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

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
setup do
content = <<CONTENT
Expand Down

0 comments on commit 4888b84

Please sign in to comment.