Add linkable titles
This commit is contained in:
parent
d5c4331921
commit
e391ddb7a1
8 changed files with 64 additions and 29 deletions
16
plugins/linkable_title.rb
Normal file
16
plugins/linkable_title.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
module Jekyll
|
||||
class LinkableTitleTag < Liquid::Tag
|
||||
def initialize(tag_name, text, token)
|
||||
super
|
||||
@title = text
|
||||
end
|
||||
|
||||
def 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue