Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use url instead of path #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/middleman-breadcrumbs/breadcrumbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(app, options_hash = {}, &block)
def breadcrumbs(page, separator: @separator, wrapper: @wrapper)
hierarchy = [page]
hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent
hierarchy.collect {|page| wrap link_to(page.data.title, "/#{page.path}"), wrapper: wrapper }.join(h separator)
hierarchy.collect { |x| wrap link_to(x.data.title, x.url), wrapper: wrapper }.join(h separator)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing the name of the block argument from page to x?

Copy link
Contributor

@vinc vinc Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably because page shadows the first page declared in the signature of the method. Let's call it p instead of x maybe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep using the path instead of switching to the URL I'd do something like URI(page.url).path or URI(x.url).path. If that's alright I'll do a new pull request with an explanation of where the old way fails for me.

end

private
Expand Down
16 changes: 8 additions & 8 deletions middleman-breadcrumbs.gemspec
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
$:.push File.expand_path("../lib", __FILE__)
require "middleman-breadcrumbs/version"
require 'middleman-breadcrumbs/version'

Gem::Specification.new do |s|
s.name = "middleman-breadcrumbs"
s.name = 'middleman-breadcrumbs'
s.version = BreadcrumbsVersion::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Marnen Laibow-Koser"]
s.email = ["[email protected]"]
s.homepage = "http://github.com/marnen/middleman-breadcrumbs"
s.authors = ['Marnen Laibow-Koser']
s.email = ['[email protected]']
s.homepage = 'http://github.com/marnen/middleman-breadcrumbs'
s.summary = %q{Breadcrumbs helper for Middleman}
s.description = %q{Breadcrumbs helper for Middleman}
s.license = 'MIT'

s.required_ruby_version = '>= 2.0'

s.add_runtime_dependency "middleman", '>= 4.0.0'
s.add_runtime_dependency 'middleman', '>= 4.0.0'
[
'byebug',
['guard', '>= 2.10.5'],
'guard-minitest',
['faker', '~> 1.5.0'],
'rake'
].each {|gem| s.add_development_dependency *gem }
].each { |gem| s.add_development_dependency(*gem) }

s.files = `git ls-files`.split("\n") - %w(.gitignore .hound.yml .hound.ruby.yml .travis.yml)
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = []
s.require_paths = ["lib"]
s.require_paths = ['lib']
end
4 changes: 2 additions & 2 deletions spec/breadcrumbs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

describe 'top-level page' do
it 'returns a link to the page' do
@helper.breadcrumbs(@page).must_equal link_to(@page.data.title, "/#{@page.path}")
@helper.breadcrumbs(@page).must_equal link_to(@page.data.title, @page.url)
end
end

Expand Down Expand Up @@ -110,7 +110,7 @@

def breadcrumb_links
[@grandparent, @parent, @page].collect do |level|
link_to level.data.title, "/#{level.path}"
link_to level.data.title, level.url
end
end

Expand Down