Add editable content helpers

This commit is contained in:
Râu Cao 2025-05-28 18:41:53 +04:00
parent 2f86b3c16f
commit 315cf4dd9f
Signed by: raucao
GPG Key ID: 37036C356E56CC51
3 changed files with 12 additions and 0 deletions

View File

@ -42,6 +42,7 @@ gem 'flipper-active_record'
gem 'flipper-ui'
gem 'gpgme', '~> 2.0.24'
gem 'zbase32', '~> 0.1.1'
gem 'kramdown'
# HTTP requests
gem 'faraday'

View File

@ -549,6 +549,7 @@ DEPENDENCIES
image_processing (~> 1.12.2)
importmap-rails
jbuilder (~> 2.7)
kramdown
letter_opener
letter_opener_web
listen (~> 3.2)

View File

@ -0,0 +1,10 @@
module EditableContentHelper
def editable_content_for(path, key, default: nil, create_rich: false)
@content = EditableContent.find_by(path: "contributions/other", key: key)
@content.content.present? ? @content.content : default
end
def markdown_to_html(string)
raw Kramdown::Document.new(string, { input: "GFM" }).to_html
end
end