Basically I was looking for a way to make filename: give the same output that Jekyll uses to parse posts, i.e. in the format of YEAR-MONTH-DAY-my-title.md so that I could iterate through it easily via {% for post in site.categories.user_posts %} ... etc
The closest I've gotten is {fields.date}-{fields.title} which gives a filename output of:
2016-11-20T21:07:36.028Z-my title.html.md
I was also wondering if you could put in a setting so we can configure the file format, like instead of .md, we could use .html?
Thanks in advance.
I'd be incredibly interested in something like this. I'm working on a news site that users can post on for my neighborhood. It would be great if people could share links to individual articles.
We want this for @opensourcedesign as well. How would we go about adding this feature to staticman?
I think we could add a special placeholder that formats a date with Moment.js (we're using it already). This should give people enough flexibility to format the path according to their requirements.
Placeholders are resolved here, so I think this should go somewhere in there.
I will try to look into this in the next couple of days, but if anyone wants to have a go at it I'm happy to assist!
I have a workaround for this feature, I'm sending the values using options[name] hidden fields, everything is preformatted on the client's side with JS, date and dashed file name, my staticman config file looks like this:
filename: "{options.submitdate}-{options.dashedtitle}"
Additionally it would be great that commitMessage: accepts placeholders too, if so we can include a title or something more related to what was submitted/sent.
@usrix I opened a separate issue for the commitMessage thing here #79
Any update on being able to set the file to a .html instead of .md, @eduardoboucas ?
@twentytwoo I've added this to the preview instance. Can you help test it? Here's how:
extension property with the extension you want to use (e.g. "html")dev.staticman.net instead of api.staticman.netThanks!
https://github.com/twentytwoo/startpages.cf/pull/42
That works great :) Thanks @eduardoboucas
Done, it's now available on the live API. So all we're missing from this issue now is the ability to manipulate the filename to include that date format, right?
Thanks a lot - That's right, I'm looking forward to it :+1:
Okay, @twentytwoo here's another one for you to test. 馃槃
I've added a special placeholder that renders the current date in any format supported by Moment.js. Here's how to test this:
dev.staticman.net instead of api.staticman.netfilename: "{@date:YYYY-MM-DD}-{fields.title}"Let me know how you get on. Thanks!
Looks like it's working well, https://github.com/twentytwoo/startpages.cf/pull/43 - Thanks again for all your hard work.
@twentytwoo Well, it took a while to land this feature, so thanks for your patience and for your help with testing. I've deployed the feature to the live API. Will close the issue as soon as I add this to the documentation.
@eduardoboucas is it possible to configure the timezone? and re-format the fields.title? i.e. to lowercase and change spaces for a dash
thanks
Finally documented placeholders: https://staticman.net/docs/placeholders
@usrix could you open a separate issue for that, please?
Thanks all!
Most helpful comment
@twentytwoo Well, it took a while to land this feature, so thanks for your patience and for your help with testing. I've deployed the feature to the live API. Will close the issue as soon as I add this to the documentation.