Comments (22)
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?
from staticman.
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:
-
Add the following to your config, where
yourContentField
is the name of the field you want to use as the post bodyformat: "frontmatter" transforms: yourContentField: "frontmatterContent"
-
Change your Staticman URL from
https://api.staticman.net
tohttps://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!
from staticman.
Great!
Closing.
from staticman.
@eduardoboucas I will at some point this week! I'll get back soon.
from staticman.
Added in #41.
from staticman.
Thanks, I'll look into this.
from staticman.
Since markdown files are not allowed as data files, a possibility is to "markdownify" a value of the yaml output: {{value | markdownify}}.
from staticman.
Yes it does make sense. That would be really great.
from staticman.
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?
from staticman.
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.
from staticman.
@thierrybgentile let me know if you get the chance to test this.
from staticman.
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
from staticman.
@usrix It should be, yes. There should be no differences between the two at the moment. What are you getting back?
from staticman.
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
from staticman.
@usrix I just redeployed. Could you try again, please?
from staticman.
@eduardoboucas, I did a few tests and it is working now!
from staticman.
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
from staticman.
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
from staticman.
Same here.
I could not send the data to the body post
Related: #91
from staticman.
Same here. dev.staticman.net works just fine but I got "undefined" whenever I use api.staticman.net.
This is a really cool feature!
from staticman.
I’m sorry that this has been an issue for so long. I’ll try to sort it in the next couple of days.
from staticman.
(Moving the discussion to #91)
from staticman.
Related Issues (20)
- When the slug is malformed, the error message cannot be parsed because it is not valid JSON
- code: 'ERR_OSSL_UNSUPPORTED' HOT 3
- Prevent javascript injection
- Supporting a more secure hash for email addresses
- Error: Require an `oauthToken` or `token` option HOT 1
- How can you change the Time Zone HOT 1
- Improve documentation for self-hosted staticman + gitlab HOT 6
- "INVALID VERSION" HOT 2
- Support for email servers other than Mailgun HOT 5
- Error: error:02000079:rsa routines::oaep decoding error HOT 1
- [GITHUB_READING_FILE]
- Gitlab and Heroku deployment
- run on vercel
- Heroku shutting down their free tier HOT 40
- Is this project still active? HOT 8
- Unexpected End of JSON Input
- Error 500 [InvalidAsn1Error]: encoding too long HOT 1
- errorCode: INVALID_VERSION when trying to accept the GitHub bot invitation HOT 3
- "errorCode":"GITLAB_READING_FILE"} HOT 2
- RSA private key encoding too long HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from staticman.