I have a blog with hundreds of articles in markdown files with YAML frontmatter.
The site is built with Jekyll and I would like to move it to Kirby.
The goal is to have all blog articles converted to Kirby-compatible files/folders with the correct permalink and the markdown content converted to Kirby blocks.
With a little bit of time, I can probably write a script to convert the markdown+frontmatter files to Kirby content files/folders. But particularly the conversion of markdown to Kirby blocks will probably take some time.
I would imagine someone has done this before. So I’m hoping to find help here?
(PS: I found this but it’s quite outdated, without documentation, and I’m not very experienced with PHP and not sure how I’d use this repo)
Thanks a lot for sharing! From what I can tell this doesn’t automatically map to Markdown, though, right?
I’d first have to turn my Markdown into HTML and from that create an array elements (headers, text, quotes etc). With that I could then convert each individual block. I guess that’s possible. I was hoping for a less manual approach.
The blocks field supports pasting of HTML content and automatically converts this pasted HTML to blocks. So I would expect it to be possible to use this feature programmatically to convert Markdown parsed to HTML into blocks.
When calling the update method, the HTML generated in $post->text()->kt() is converted into Kirby Blocks of type header, image, text, list… automatically. If you want to keep everything in a single field, that’s fine.
In my case, what I find is that the image blocks were transformed to images with absolute paths in which you could not work well for the migration and I had to detect the image blocks and modify them so that they were inside the Kirby panel.
I leave you a Gist that I have published for you to see, I hope it sheds a little light on you.