From e704afbd74867be063c992d414c8d5b29deb1a7f Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 13 Nov 2019 14:54:11 -0800 Subject: [PATCH] Link to URLs without ".html" at the end --- helpers/sass_helpers.rb | 4 ++++ source/blog.html.haml | 6 +++--- source/feed.xml.builder | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/helpers/sass_helpers.rb b/helpers/sass_helpers.rb index 66ed06f..635b582 100644 --- a/helpers/sass_helpers.rb +++ b/helpers/sass_helpers.rb @@ -51,6 +51,10 @@ module SassHelpers pages.flatten end + def without_html(page) + url_for(page).sub(/\.html$/, '') + end + def documentation_toc _toc_level(nil, data.documentation.toc) end diff --git a/source/blog.html.haml b/source/blog.html.haml index 63eea42..2600c1f 100644 --- a/source/blog.html.haml +++ b/source/blog.html.haml @@ -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 diff --git a/source/feed.xml.builder b/source/feed.xml.builder index 7cee5c7..3ec08ee 100644 --- a/source/feed.xml.builder +++ b/source/feed.xml.builder @@ -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