usar el editor en otros campos

como reemplazo del campo `markdown` que coloca texto con markdown en el
front matter.
This commit is contained in:
f 2021-04-22 13:09:49 -03:00
parent c9531af77b
commit 70e64e6e97
3 changed files with 25 additions and 3 deletions

View file

@ -15,14 +15,18 @@ class MetadataContent < MetadataTemplate
false
end
def document_value
document.content
end
private
# Detectar si el contenido estaba en Markdown y pasarlo a HTML
def legacy_content
return unless document.content
return document.content if /^\s*</ =~ document.content
return unless document_value
return document_value if /^\s*</ =~ document_value
CommonMarker.render_doc(document.content, %i[FOOTNOTES UNSAFE], %i[table strikethrough autolink]).to_html
CommonMarker.render_doc(document_value, %i[FOOTNOTES UNSAFE], %i[table strikethrough autolink]).to_html
end
# Limpiar el HTML que recibimos

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
# Campos en HTML
class MetadataHtml < MetadataContent
def front_matter?
true
end
def document_value
document.data[name.to_s]
end
end

View file

@ -0,0 +1,6 @@
-# Editor de contenido
= render 'posts/attributes/content',
base: 'post', post: post, attribute: attribute,
metadata: metadata, site: site,
dir: dir, locale: locale,
autofocus: (post.attributes.first == attribute)