First I want to say this project is amazing and thank you for it. One of the first things that came to mind when I heard about it is the possibility to make an open publishing kind of blog/platform out of it. In fact I'm doing that right now. I want to point the path in a Jekyll blog to _posts/ and see if i can make this work such that the form generates markdown files with a few markdown fiels at the top. I guess to make that work ideally we'd need support for markdown as well, not just YAML and JSON, right?
How easy would that be to build in? I'm interested in contributing though I'm mostly a begginner javascript dev.
Thanks! I'm glad you find it useful.
That's a very interesting idea. What you need is effectively a way of outputting a Markdown file with the front-matter format used by Jekyll to create a post (which is effectively Markdown), as well as the post body.
The first option that comes to mind is to add a new output format (called post perhaps), as well as a new transform type (called post-body).
_Form example:_
<input type="hidden" name="fields[category]" value="music">
<input type="text" name="fields[title]">
<textarea name="fields[body]"></textarea>
_Staticman config:_
format: 'post'
transforms:
body: 'post-body' # This will tell Staticman that this field is the post body
_Output:_
category: "music"
title: "Whatever is typed into title"
---
Whatever is typed into the post body. It can have Markdown or HTML, Staticman doesn't care
Does that make sense?
Yes it does make sense. That would be really great.
I'm think it would be useful to spin up a test instance of the Staticman API (on a free Heroku instance) to test new features. Would you be able to assist with test driving this once I implement?
I'll do my best! I don't know much about testing but I'll look it up and test as much stuff as I can with my little prototype.
I was finally able to look at this (sorry I took ages). I've pushed this feature to a new test instance. Here's how you can use it:
yourContentField is the name of the field you want to use as the post bodyyaml
format: "frontmatter"
transforms:
yourContentField: "frontmatterContent"
https://api.staticman.net to https://dev.staticman.net.It's a test instance, so it might be a bit slow. Can you give it a test, see if it does what you're after and let me know of any issues?
Thanks!
@thierrybgentile let me know if you get the chance to test this.
@eduardoboucas I will at some point this week! I'll get back soon.
Added in #41.
Is the frontmatterContent transformation working from api.staticman? I tested on dev.staticman and it is working but on api (master) it is not, it returns undefinied, thanks
@usrix It should be, yes. There should be no differences between the two at the moment. What are you getting back?
@eduardoboucas
Using api.staticman I get undefined in the markdown body
YAML block:
fieldone: field text
fieldname: field name text
---
undefined
Using dev.staticman
I get:
fieldone: field text
---
field name text
Thanks, I'll look into this.
@usrix I just redeployed. Could you try again, please?
@eduardoboucas, I did a few tests and it is working now! :+1:
Great! 馃帀
Closing.
hey @eduardoboucas
After testing different scenarios, one came out, when the frontmatter field is not required (optional) and is not sent to staticman, the markdown part is generated as "undefined", I think it would be better to skip it on those cases
@eduardoboucas
I'm having the same issue than last time,
api.staticman
is displaying the "frontmatterContent" in the yaml block and the markdown body undefined
dev.staticman
Is working correctly
Same here.
I could not send the data to the body post :sob:
Related: https://github.com/eduardoboucas/staticman/issues/91
Same here. dev.staticman.net works just fine but I got "undefined" whenever I use api.staticman.net.
This is a really cool feature! :smiley:
I鈥檓 sorry that this has been an issue for so long. I鈥檒l try to sort it in the next couple of days.
Since markdown files are not allowed as data files, a possibility is to "markdownify" a value of the yaml output: {{value | markdownify}}. :ok_hand:
(Moving the discussion to #91)
Most helpful comment
Great! 馃帀
Closing.