Skip to content

ruby gem for converting yaml files to index.json and index.csv

License

Notifications You must be signed in to change notification settings

BenRuns/jekyll-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jekyll-Json

Gem Version

This gem is created to be used with jekyll webpages. It will take a yaml file and build an index.csv file or an index.json file in the folder that you specify in _config.yml

Installing

Add the following to your gemfile

group :jekyll_plugins do
  gem 'jekyll-json'
end

In your _config.yml add

gems:
- jekyll-json

and something like the following

serve-json-csv:
  - destination: "foldername"
    origin: "_path_from_root/to_your_data.yml"
    csv: true
    json: true
    headers: [name, description, link_url, code_url, type, categories, status]
    filter-json: true

The headers are required if you're creating a csv file or if you set filter-json to true

For example: Given a yml file that looks like

- name: "Jack"
  country: "Australia"
  etc: "likes cake"
  pail: "empty"
  
- name: "Jill"
  country: "Oz"
  etc: "likes ice cream"
  pail: "full"
  

and set the headers to: [name,country, etc]

This will produce an index.csv file

name, country, etc
Jack, Australia, likes cake
Jill, Oz,likes ice cream

if filter-json is set to true, then it will produce an index.json file

[{
    name: "Jack",
    country: "Australia",
    etc: "likes cake"
},
{
    name: "Jill",
    country: "Oz",
    etc: "likes ice cream"
}]

if filter-json is set to false, then it will produce an index.json file

[{
    name: "Jack",
    country: "Australia",
    etc: "likes cake",
    pail: "empty"
},
{
    name: "Jill",
    country: "Oz",
    etc: "likes ice cream",
    pail: "full"
}]

Set csv and json to true or false depending on whether you want corrsponding file type generated.

run jekyll build to generate the files

Contributing.

Let me know if there are issues you're running into . This is a first release and there is still plenty of work to put in to make this less fragile. Fork the repo, make a pull request etc...

About

ruby gem for converting yaml files to index.json and index.csv

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages