diff --git a/app/_plugins/kuma-specific/custom-block.rb b/app/_plugins/kuma-specific/custom-block.rb new file mode 100644 index 000000000000..4b91b04d22ff --- /dev/null +++ b/app/_plugins/kuma-specific/custom-block.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Jekyll + class CustomBlock < Liquid::Block + def initialize(tag_name, markup, options) + super + # Classes differs between Kuma and Kong docs, but they have the same + # underlying meanings + @class_name = { + "tip" => "note", + "warning" => "important", + "danger" => "warning" + }.fetch(tag_name, "note") + end + + def render(context) + content = Kramdown::Document.new(super).to_html + <<~HTML +
++ HTML + end + end +end + +Liquid::Template.register_tag('tip', Jekyll::CustomBlock) +Liquid::Template.register_tag('warning', Jekyll::CustomBlock) +Liquid::Template.register_tag('danger', Jekyll::CustomBlock) diff --git a/app/_plugins/kuma-specific/tip.rb b/app/_plugins/kuma-specific/tip.rb deleted file mode 100644 index 4862fb33cd28..000000000000 --- a/app/_plugins/kuma-specific/tip.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Jekyll - class Tip < Liquid::Block - def initialize(tag_name, markup, options) - super - - @markup = markup.strip - end - - def render(context) - content = Kramdown::Document.new(super).to_html - <<~TIP -#{content}
+
-- TIP - end - end -end - -Liquid::Template.register_tag('tip', Jekyll::Tip) diff --git a/app/_plugins/kuma-specific/warning.rb b/app/_plugins/kuma-specific/warning.rb deleted file mode 100644 index 2880bd07420f..000000000000 --- a/app/_plugins/kuma-specific/warning.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -module Jekyll - class Warning < Liquid::Block - def initialize(tag_name, markup, options) - super - - @markup = markup.strip - end - - def render(context) - content = Kramdown::Document.new(super).to_html - - # warnings in Kuma map to {:.important} in docs - <<~TIP -#{content}
-
-- TIP - end - end -end - -Liquid::Template.register_tag('warning', Jekyll::Warning)#{content}
-