diff --git a/lib/middleman-title/helpers.rb b/lib/middleman-title/helpers.rb index 5186085..af4a7ce 100644 --- a/lib/middleman-title/helpers.rb +++ b/lib/middleman-title/helpers.rb @@ -3,6 +3,9 @@ module Title module Helpers def page_title + current_page_title = current_page.data.page_title + return current_page_title unless current_page_title.nil? + title = [] title = add_page_name_to_title(title) title = add_website_name_to_title(title) diff --git a/spec/extension_spec.rb b/spec/extension_spec.rb index e93edbe..a242772 100644 --- a/spec/extension_spec.rb +++ b/spec/extension_spec.rb @@ -12,6 +12,7 @@ h.stub_chain(:current_page, :data, :title).and_return(nil) h.stub_chain(:current_page, :data, :title_site).and_return(nil) h.stub_chain(:current_page, :data, :title_reverse).and_return(nil) + h.stub_chain(:current_page, :data, :page_title).and_return(nil) end context 'website name is set' do @@ -93,5 +94,13 @@ end + context 'page_title is set' do + before(:each) { h.stub_chain(:current_page, :data, :page_title).and_return('This takes precedence') } + + it 'returns page_title specified for the current page' do + expect(h.page_title).to eq 'This takes precedence' + end + end + end end