Permalink
Browse files

Set default link text for home page to 'Home'.

I've also added the 'Link text' metadata to the default template, just
to be explicit about how you can change it.
  • Loading branch information...
1 parent 86cf36b commit 59bb77012e1c90b9f0b57aa20f95a3f253728449 @gma gma committed May 9, 2012
Showing with 14 additions and 4 deletions.
  1. +12 −4 lib/nesta/navigation.rb
  2. +2 −0 templates/index.haml
View
16 lib/nesta/navigation.rb
@@ -24,7 +24,7 @@ def display_menu_item(item, options = {})
html_class = current_item?(item) ? "current" : nil
haml_tag :li, :class => html_class do
haml_tag :a, :<, :href => url(item.abspath) do
- haml_concat item.link_text
+ haml_concat link_text(item)
end
end
end
@@ -45,16 +45,24 @@ def display_breadcrumbs(options = {})
breadcrumb_ancestors[0...-1].each do |page|
haml_tag :li do
haml_tag :a, :<, :href => url(page.abspath) do
- haml_concat breadcrumb_label(page)
+ haml_concat link_text(page)
end
end
end
- haml_tag(:li) { haml_concat breadcrumb_label(@page) }
+ haml_tag(:li) { haml_concat link_text(@page) }
end
end
+ def link_text(page)
+ page.link_text
+ rescue LinkTextNotSet
+ return 'Home' if page.abspath == '/'
+ raise
+ end
+
def breadcrumb_label(page)
- (page.abspath == '/') ? 'Home' : page.link_text
+ Nesta.deprecated('breadcrumb_label', 'use link_text')
+ link_text(page)
end
def current_item?(item)
View
2 templates/index.haml
@@ -1 +1,3 @@
+Link text: Home
+
%section.articles= article_summaries(latest_articles)

0 comments on commit 59bb770

Please sign in to comment.