Commit ae9d7481 authored by Tobias Schmidt's avatar Tobias Schmidt

Handle embedded images in repository docs

parent b20ed77d
......@@ -33,6 +33,14 @@ route '/assets/*' do
end
end
# TODO(ts): Remove these hacks once the nanoc4 upgrade is done.
compile '*/images/*' do
end
route '*/images/*' do
item.identifier.chop + '.' + item[:extension]
end
route '/README/' do
'/README.md'
end
......
......@@ -9,9 +9,8 @@ class NormalizeLinks < ::Nanoc::Filter
def run(content, config = {})
doc = Nokogiri::HTML(content)
links = doc.xpath('//a')
links.each do |link|
doc.xpath('//a').each do |link|
link['href'] =
case
when link['href'].start_with?(DOMAIN)
......@@ -26,6 +25,11 @@ class NormalizeLinks < ::Nanoc::Filter
end
end
doc.xpath('//img').each do |img|
next if img['src'].start_with?('/') || img['src'].start_with?('http')
img['src'] = File.join("../", img['src'])
end
doc.to_s
end
......
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