I have been playing around with Jekyll for some time. In some scenarios, I feel the functionality is limited. So I plan to augment my site in this way:
- Only using Jekyll to render some fixed and basic components (backward compatible with the environments that do not support JS).
- Use Jekyll to output meta data, e.g. XML or JSON.
- Use client side JS and the meta data to provide richer functions.
When the required fields are fixed, the task is easy. e.g. may people use Jekyll to generate RSS (xml) feeds; some people use Jekyll to generate a search index (xml with "title", "date", etc).
Now I want to give more freedom to end users of my template so I do not limit what fields are used in the YAML front-matter. Is there a convenient way to convert the full YAML front-matter to JSON to XML format?
I did not find the support of dumping full YAML front-matter in Jekyll or Liquid manual. If I output {{ page }}
directly, this is the result:
{"name"=>"Google", "date"=>#, "link"=>"http://google.com/", "open_source"=>false, "open_format"=>false, "rate_use"=>10, "rate_quality"=>9, "tags"=>["Google", "Search Engine", "Information Retrieval"], "language"=>"en", "layout"=>"default", "mathjax"=>false, "url"=>"/sample/google.html", "content"=>"The search engine I use everyday. \n\n"}
At least two problems:
- I need a ruby-to-JSON/XML converter in JS. (or a parser to directly read this as a JS data structure).
- Some fields are not output correctly, e.g. the
date
.
Hope someone can point me to relevant resources and previous trials like this.
Many thanks.
(this is a redirect from jekyll-rb Google Group to get quicker response)
Related questions:
- Jekyll - generating JSON files alongside the HTML files . The pointer of JekyllBot is useful but requires more setup. I don't want to bother my end users. The best is to only use standard Jekyll and Liquid facilities.