Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(plugins/kuma): refactor custom block plugins specific to Kuma #8078

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions app/_plugins/kuma-specific/custom_block.rb
Original file line number Diff line number Diff line change
@@ -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
<blockquote class="#{@class_name}">
<p>#{content}</p>
</blockquote>
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)
22 changes: 0 additions & 22 deletions app/_plugins/kuma-specific/tip.rb

This file was deleted.

24 changes: 0 additions & 24 deletions app/_plugins/kuma-specific/warning.rb

This file was deleted.

Loading