mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-05-08 03:59:00 +00:00
17 lines
457 B
Ruby
17 lines
457 B
Ruby
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
|
|
|
|
Liquid::Template.register_tag('linkable_title', Jekyll::LinkableTitleTag)
|