sparkartgroup / gulp-markdown-to-json

Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
MIT License
75 stars 14 forks source link

Can I hide "body" in json? #6

Closed oxxostudio closed 8 years ago

oxxostudio commented 9 years ago

Can I hide "body" in json? If I can, how to do? Thank you very much. ^_^

pushred commented 9 years ago

Hmm the HTML output is kinda core, can you explain the use case a bit? Are you using this to generate an index / navigation of some sort, where the content isn't important?

oxxostudio commented 9 years ago

Because my JSON files Only used as navigation, There may be more than 100 data ( markdown file ) And the contents of each is based on JSON (use AJAX) The flow like this: Edit Markdown-> JSON + HTML-> combine layout-> Web site Just wanted to know, can I use "body: true" or "body: false" function? ^^ ( Incidentally, your plugin is very helpful~ thank you!!! ^^ )

pushred commented 9 years ago

Ah ok I think I understand. Are you using the multiple file output for the content on each of the individual pages and looking to use the single file option for your navigation? That use case makes sense.. I'd perhaps rather expose another method to generate this nav index as I'd rather not mix the config for the Markdown parser with options for the plugin (or have a separate object for that).

pushred commented 8 years ago

If you're still using this plugin by chance I finally got around to a solution. #14 adds an optional transform function that you can use like this:

gulp.src('./content/**/*.md')
  .pipe(gutil.buffer())
  .pipe(markdownToJSON(marked, (data, file) => {
    delete data.body;
    return data;
  }))
  .pipe(gulp.dest('.'))
oxxostudio commented 8 years ago

WOW, that's awesome! thank you very much. ;)