Gulp Yaml Front Matter to JSON add File Name -


I'm not sure what the best way to go about it.

I would like to add a yaml front case to the json from a markdown file by adding a file name to a single array Jason file.

Example files bananas.md and apples.md ,

  --- title: Ban Type: yellow Calculation: - 1 - 2 - - # My Markdown file   

Apple MD :

  --- Title: Apple Type: Red Count: - 3 - 4 --- # My Markdown File 2   

all.json :

  [["title" "" "" "" "" "" "" "" " "," "Type": "yellow", "count": [1,2], "file": "banana"}, {"title": "apple", "type": "red", "count" [3,4], "file": "apple"}]   

Of course, there will be no return because it will be compact.

Let me know something like Gulppass Plugins have been found but do not seem to have them No one really wants what I want, even not even joint, as long as I'm missing something.

Update , I created the plugin gulp-pluck , which is a very simple process.

How it works here Is:

  var gulp = require ('gulp'); var data = required ('crypto data'); Var pluck = is required ('gulp-plaque') ; Var Frontimator = is required ('gulp-front-case'); Gulp.task ('front-matter-to-json', function) (return gulp.src ('./posts/ * .md') .pipe (frontmaker ({property: 'meta'})) .pipe (File (file.meta.path = file.path;}).) .pipe ('meta', 'post-metadata.jason')) .pipe (data (function (file) {file. Content = new Buffer (JSON.stringify (file.meta))}.) .pipe (gulp.dest ('dist')})   

end update < / P>


Okay, take the time to take the time. Gulp needs a built-in low function!

Dependencies include: cryptography, Filter , event-stream , stream-less , and gulp-rename .

:

  Gulpacakas 'constanm' - & gt; DevDest = './dev/public/' gulp.src './src/posts/*.md' .pipe filter post .pip front-case {property: 'meta'} .pipe es.map (file, cb) - & gt; File.meta.name = path.basename file.path file.meta.url = toUrlPath file.meta.name cb faucet, file. Reduce the pipe (ACC, file) - & gt; | Acc = & gt; Acc.meta.push File.meta acc | _ = & Gt; Acc = file acc.meta = [file.meta] ac), zero. Pipe es.map (file, cb) - & gt; File.contents = New buffer JSON.stringify file.meta cb null, Rename the file .pipe 'posts.json' .pipe gulp.dest devDest   

and JavaScript Equivalent:

  Gulppasskas ('concatyaml', function) (var devDest; devDest = './dev/public/'; return gulp.src ('./src / posts / (file , Cb {file.meta.name = path} .pipe (filter) .pipe (front property ({property: 'meta'}) .pipe (es.map (function (file, cb) {file .meta.name = path (f, file) {switch (false) {decrease} (file). File (file); file meta.url = to url path (file.mata.name); return CB (tap, file );}). Mal: acc: acc.meta.push (file.meta); return ac; default: acc = file; acc.meta = [file.meta]; return ac;}}, zero 8)) .pipe (es.map (Function (file, cb) {file.contents = new buffer (JSON.stringify (file.meta)); return CB (faucet, file);}) .pipe (rename ('posts.json')). Pipes (Gulp.dest (devDest));});    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -