Skip to content

Commit

Permalink
Link to URLs without ".html" at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Israel-4Ever authored and Natalie Weizenbaum committed Nov 13, 2019
1 parent 5112ddf commit 9fa5780
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions helpers/sass_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def pages_for_group(group_name)
pages.flatten
end

def without_html(page)
url_for(page).sub(/\.html$/, '')
end

def documentation_toc
_toc_level(nil, data.documentation.toc)
end
Expand Down
6 changes: 3 additions & 3 deletions source/blog.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ per_page: 5

- if paginate && num_pages > 1
%p Page #{page_number} of #{num_pages}
%p= link_to 'Previous page', prev_page if prev_page
%p= link_to 'Previous page', without_html(prev_page) if prev_page

- page_articles.each_with_index do |article, i|
%h2= link_to article.title, article
%h2= link_to article.title, without_html(article)
= partial 'layouts/components/attribution', locals: {page: article}
= article.summary

- if paginate
%p= link_to 'Next page', next_page if next_page
%p= link_to 'Next page', without_html(next_page) if next_page
2 changes: 1 addition & 1 deletion source/feed.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ xml.feed xmlns: "http://www.w3.org/2005/Atom" do

blog.articles[0..5].each do |article|
xml.entry do
url = config[:host] + article.url
url = config[:host] + without_html(article.url)
xml.title article.title
xml.link href: url, rel: "alternate"
xml.id url
Expand Down

0 comments on commit 9fa5780

Please sign in to comment.