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

The order of the consolidated output [Question] #18

Closed levsthings closed 7 years ago

levsthings commented 8 years ago

When combining bunch of Markdown files into a single JSON file, do we have any control over the order of objects? It appears that Markdown files are being added in an alphabetical order of their respective filename.

I'm using the task below:

gulp.task('indexContent', () => {
  gulp.src('./content/**/*.md')
    .pipe(gutil.buffer())
    .pipe(markdownToJSON(marked, 'content/json/index.json'))
    .pipe(gulp.dest('.'))
});
pushred commented 8 years ago

Sorting is handled by the sort-object module, this is applied after all async processing has completed. That module does provide a couple hooks to write custom sort functions, would that be a good solution for your needs? I could expose access in the plugin's options.

pushred commented 8 years ago

Another option that's perhaps better: the gulp-json-sort plugin provides a similar sort function

levsthings commented 7 years ago

Thank you for the suggestions, gulp-json-sort does the trick!

pushred commented 7 years ago

Great! I'll add a note about it in the readme on the next update