-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverse generating a file #26
Comments
Hi @qimingweng! Actually yeah, @bcomnes had brought this up in the past in #16. I think it's a good idea, and probably warrants a new major version bump. Before submitting a PR lets settle on/work out an API for how this would work, some requirements/questions off the top of my head:
Do you have a specific use-case in mind? I am curious to learn how you are using front-matter and how you intend to use this new feature. |
Ah yes, streams would be the most "ideal" way to do this I suppose, although I'm not sure it would really be that effective. You could always just have everything done in memory but expose it as a stream for people so that the API can be consistent in the future if and when performance really can be sped up with a stream. Or even if it's just to play nice with the read and write file APIs on the Something I was thinking about was that all the comments would get lost in the rewrite from object back to YAML... But maybe there can be some kind of proprietary API around that (actually that's probably a bad idea). Anyway, I use a folder of markdown files as kind of a small database for internal business intelligence. It's much easier for people at the company to understand. I can see times where I would want to automate some of the routine updates or cleaning of the files though - that's where the reverse part of it would happen. Or if I ever wanted the API to actually write those files back (although if it ever gets that complex I think maybe I would just use a real database). |
This is supported in a module I published recently: https://github.com/IonicaBizau/mdify It's more related to Markdown world, but for this specific task, it will probably work nicely (see the const mdify = require("mdify");
let md = mdify.stringify({
author: "Johnny B."
, date: new Date()
, tags: ["hello", "world"]
}, `## Hello World!
Hey **there**!`);
console.log(md);
// ---
// author: Johnny B.
// date: 2016-06-06T07:12:17.533Z
// tags:
// - hello
// - world
// ---
// ## Hello World!
// Hey **there**! |
Just curious if there are any plans to support the reverse action; which is to take a object with "attributes" and "body" and return a string to be written to a file?
Or if you would be open to accepting a PR with that functionality.
The text was updated successfully, but these errors were encountered: