Comments (3)
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:
- front-matter should not do any file IO directly, but should interop easily with fs APIs.
- There was a feature suggestion to support streams (#24), what would a stream API for the "reverse" feature look like?
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.
from front-matter.
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 fs
package. I don't have too much experience actually writing streams.
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).
from front-matter.
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 stringify
method):
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**!
from front-matter.
Related Issues (20)
- Typescript types are broken. HOT 4
- yaml.safeLoad() HOT 6
- Please add Yarn support .. HOT 6
- Serializer too HOT 1
- Add v4 Changelogs
- The types don't represent the module correctly
- Frontmatter date parsing oddities HOT 3
- Very large size in browser bundle HOT 1
- Uncaught SyntaxError: Unexpected token ... ,run error in Hybrid Mobile App HOT 1
- yaml.safeLoad is removed in js-yaml 4. Use yaml.load instead HOT 1
- Do not convert entities like "."
- Dead project? HOT 3
- Why only YAML support ? HOT 2
- v5
- Reserved characters/list requiring quoting? HOT 1
- How to Preserve break lines
- Attributes is empty HOT 3
- test() doesn't check that frontmatter is at the front
- bodyBegin behaves unexpectedly
- Create a Security Policy
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 front-matter.