forked from home-assistant/home-assistant.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔥Removes linkable_title everywhere (home-assistant#9772)
* Automatically create linkable headers * Visually improve position of linkable header chain icon * Do not auto link headers on homepage * Remove linkable_title everywhere * 🚑 Re-instante linkable_title plugin as NOOP
- Loading branch information
Showing
1,002 changed files
with
4,820 additions
and
4,801 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
module Jekyll | ||
class LinkableTitleTag < Liquid::Tag | ||
def initialize(tag_name, text, token) | ||
super | ||
@title = text | ||
end | ||
module Jekyll | ||
class LinkableTitleTag < Liquid::Tag | ||
def initialize(tag_name, text, token) | ||
super | ||
@title = text | ||
end | ||
|
||
def render(context) | ||
title = Liquid::Template.parse(@title).render context | ||
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') | ||
"<a class='title-link' name='#{slug}' href='\##{slug}'></a> #{title}" | ||
end | ||
end | ||
end | ||
def render(context) | ||
title = Liquid::Template.parse(@title).render context | ||
"#{title}" | ||
end | ||
end | ||
end | ||
|
||
Liquid::Template.register_tag('linkable_title', Jekyll::LinkableTitleTag) | ||
Liquid::Template.register_tag('linkable_title', Jekyll::LinkableTitleTag) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Jekyll Out Modder - Allows for mangling/modding the HTML output | ||
# | ||
# This is combined in a single plugin/filter to reduce the NokoGiri dom | ||
# parsing to just once per page/content. | ||
# | ||
# - Automatically adds rel='external nofollow' to outgoing links. | ||
# - Automatically make headers linkable | ||
# | ||
require 'jekyll' | ||
require 'nokogiri' | ||
|
||
module Jekyll | ||
module OutputModder | ||
def output_modder(content) | ||
dom = Nokogiri::HTML.fragment(content) | ||
|
||
# Find all links, make all external links rel='external nofollow' | ||
dom.css('a').each do |link| | ||
rel = ['external', 'nofollow'] | ||
|
||
# All external links start with 'http', skip when this one does not | ||
next unless link.get_attribute('href') =~ /\Ahttp/i | ||
|
||
# Play nice with our own links | ||
next if link.get_attribute('href') =~ /\Ahttps?:\/\/\w*.?home-assistant.io/i | ||
|
||
# Play nice with links that already have a rel attribute set | ||
rel.unshift(link.get_attribute('rel')) | ||
|
||
# Add rel attribute to link | ||
link.set_attribute('rel', rel.join(' ').strip) | ||
end | ||
|
||
# Find all headers, make them linkable | ||
dom.css('h2,h3,h4,h5,h6,h7,h8').each do |header| | ||
|
||
# Skip linked headers | ||
next if header.at_css('a') | ||
|
||
title = header.content | ||
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') | ||
header.children = "<a class='title-link' name='#{slug}' href='\##{slug}'></a> #{title}" | ||
end | ||
|
||
dom.to_s | ||
end | ||
end | ||
end | ||
|
||
Liquid::Template.register_filter(Jekyll::OutputModder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.