Coder Social home page Coder Social logo

Reverse generating a file about front-matter HOT 3 OPEN

jxson avatar jxson commented on August 13, 2024
Reverse generating a file

from front-matter.

Comments (3)

jxson avatar jxson commented on August 13, 2024

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.

qimingweng avatar qimingweng commented on August 13, 2024

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.

IonicaBizau avatar IonicaBizau commented on August 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.