Sha256: a123e38c8c332b45c630cff28ad6d379689563d63a530e020a4f29b1617c7b6f
Contents?: true
Size: 906 Bytes
Versions: 17
Compression:
Stored size: 906 Bytes
Contents
require 'nokogiri' require 'uri' def process_content(site_hostname, content) content = Nokogiri::HTML(content) content.css('body.site--project main a, body.site--hub.layout--post main a').each do |a| next unless a.get_attribute('href') =~ /\Ahttp/i next if a.get_attribute('href').include? site_hostname a.set_attribute('rel', 'external') a.inner_html = "#{a.inner_html}<span class='ico-ext'><i class='fas fa-external-link-square'></i></span>" end return content.to_s end Jekyll::Hooks.register :documents, :post_render do |doc| site_hostname = URI(doc.site.config['url']).host unless doc.asset_file? doc.output = process_content(site_hostname, doc.output) end end Jekyll::Hooks.register :pages, :post_render do |page| site_hostname = URI(page.site.config['url']).host unless page.asset_file? page.output = process_content(site_hostname, page.output) end end
Version data entries
17 entries across 17 versions & 1 rubygems