Unverified Commit 8fd09e40 authored by Richard Hartmann's avatar Richard Hartmann Committed by GitHub

Merge pull request #1175 from prometheus/grobie/fix-absolute-markdown-links

Fix absolute links to markdown pages in repo docs
parents a882708b 0fbc0cba
# encoding: utf-8 # encoding: utf-8
require 'nokogiri' require 'nokogiri'
require 'uri'
class NormalizeLinks < ::Nanoc::Filter class NormalizeLinks < ::Nanoc::Filter
identifier :normalize_links identifier :normalize_links
...@@ -18,7 +19,7 @@ class NormalizeLinks < ::Nanoc::Filter ...@@ -18,7 +19,7 @@ class NormalizeLinks < ::Nanoc::Filter
when link['href'].start_with?('/') when link['href'].start_with?('/')
# TODO(ts): It's not guaranteed that a repository is hosted on Github. # TODO(ts): It's not guaranteed that a repository is hosted on Github.
github_link_to(link['href'], config) github_link_to(link['href'], config)
when link['href'].include?('.md') when link['href'].include?('.md') && !URI.parse(link['href']).absolute?
relative_link_to(link['href']) relative_link_to(link['href'])
else else
link['href'] link['href']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment