mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 02:11:42 +00:00
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:
parent
c9531af77b
commit
70e64e6e97
3 changed files with 25 additions and 3 deletions
|
@ -15,14 +15,18 @@ class MetadataContent < MetadataTemplate
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def document_value
|
||||||
|
document.content
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Detectar si el contenido estaba en Markdown y pasarlo a HTML
|
# Detectar si el contenido estaba en Markdown y pasarlo a HTML
|
||||||
def legacy_content
|
def legacy_content
|
||||||
return unless document.content
|
return unless document_value
|
||||||
return document.content if /^\s*</ =~ document.content
|
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
|
end
|
||||||
|
|
||||||
# Limpiar el HTML que recibimos
|
# Limpiar el HTML que recibimos
|
||||||
|
|
12
app/models/metadata_html.rb
Normal file
12
app/models/metadata_html.rb
Normal 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
|
6
app/views/posts/attributes/_html.haml
Normal file
6
app/views/posts/attributes/_html.haml
Normal 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)
|
Loading…
Reference in a new issue