Recently I’ve concluded that Markdown is not a good fit for my orchard core blog. My blog is on two languages English and Persian. And markdown is too limited for Persian specifically its lack of RTL support. So I decided to switch to an Html editor for blog posts. Editing the blog post content type is simple but I need to migrate my old posts' text to the new editor field and I need to show the content of this HTML editor on the page, not the markdown one.
After a little search, I find out that I should change these types of things with templates, previously I thought I should change them by modifying a view file or something but as it turns out I just needed to add a template with the name Content__BlogPost which I found it under BlogPost part edit, edit templates drop-down button then “Template for Blog Post content item in detail views.
Then copied the orchard core source for TheBlogTheme views, Content-BlogPost.liquid which is what currently is being used I pasted the content to the new template content and just changed the part with markdown rendering on it to HTML rendering.
Before:
{{ Model.Content.MarkdownBodyPart | shape_render }}
After:
{{ Model.Content.HtmlBodyPart | shape_render }}
I saved it and it worked like a charm 😊
But now I have to copy and paste the content from my markdown field to HTML field and edit each post a bit. Let’s see if I can find a way to copy the markdown field to the HTML field.
Maybe I can do it with a query on the database. Yeah, it’s not that complicated with a query it just needs to filter the content column in the document table where "ContentType":"BlogPost" and change the word Markdown to Html.
But due to the changes required for MD to render well as HTML, I had to edit them one by one I chose to keep both parts in the blog post and migrate the content one by one.
By the way, I chose Trumbowyg editor for the HTML editor type. It looks more featureful. I’ll share my thoughts when I have more experience with it.
As of now, it turns out copying and pasting is easier for editing than updating the content using a query. The formatting is a nightmare. 😊