mirror of
https://github.com/bitwarden/help
synced 2026-01-21 11:53:27 +00:00
alert and callout plugins
This commit is contained in:
27
_plugins/alert.rb
Normal file
27
_plugins/alert.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
# Source: https://stackoverflow.com/questions/19169849/how-to-get-markdown-processed-content-in-jekyll-tag-plugin
|
||||
|
||||
module Jekyll
|
||||
module Tags
|
||||
class AlertTag < Liquid::Block
|
||||
def initialize(tag_name, type, tokens)
|
||||
super
|
||||
type.strip!
|
||||
if %w(info danger warning).include?(type)
|
||||
@type = type
|
||||
else
|
||||
puts "#{type} alert not supported. Defaulting to info"
|
||||
@type = "info"
|
||||
end
|
||||
end
|
||||
|
||||
def render(context)
|
||||
site = context.registers[:site]
|
||||
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
|
||||
output = converter.convert(super(context))
|
||||
"<div class=\"alert alert-#{@type}\">#{output}</div>"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('alert', Jekyll::Tags::AlertTag)
|
||||
27
_plugins/callout.rb
Normal file
27
_plugins/callout.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
# Source: https://stackoverflow.com/questions/19169849/how-to-get-markdown-processed-content-in-jekyll-tag-plugin
|
||||
|
||||
module Jekyll
|
||||
module Tags
|
||||
class CalloutTag < Liquid::Block
|
||||
def initialize(tag_name, type, tokens)
|
||||
super
|
||||
type.strip!
|
||||
if %w(info danger warning).include?(type)
|
||||
@type = type
|
||||
else
|
||||
puts "#{type} callout not supported. Defaulting to info"
|
||||
@type = "info"
|
||||
end
|
||||
end
|
||||
|
||||
def render(context)
|
||||
site = context.registers[:site]
|
||||
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
|
||||
output = converter.convert(super(context))
|
||||
"<div class=\"callout callout-#{@type}\">#{output}</div>"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('callout', Jekyll::Tags::CalloutTag)
|
||||
Reference in New Issue
Block a user