Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow json files in _data dir #2369

Merged
merged 4 commits into from May 9, 2014
Merged

Allow json files in _data dir #2369

merged 4 commits into from May 9, 2014

Conversation

benbalter
Copy link
Contributor

Per @holic's excellent comment over in github/pages-gem#64 (comment), any valid JSON with a .yaml extension in the _data directory is valid YAML and can be read it. Tested locally, and it appears to be true.

This pull request simply expands the allowed file extensions to be read in from yml and yaml to also include json.

Todo

  • Tests
  • Update docs

@holic
Copy link
Contributor

holic commented May 9, 2014

👍

@@ -22,7 +22,7 @@ Plugins/themes can also leverage Data Files to set configuration variables.

As explained on the [directory structure](../structure/) page, the `_data`
folder is where you can store additional data for Jekyll to use when generating
your site. These files must be YAML files (using either the `.yml` or `.yaml`
your site. These files must be YAML files (using either the `.yml`, `.yaml` or `json`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot a dot 😄

@mattr-
Copy link
Member

mattr- commented May 9, 2014

❤️ Thanks @benbalter!

mattr- added a commit that referenced this pull request May 9, 2014
@mattr- mattr- merged commit 50065a2 into master May 9, 2014
mattr- added a commit that referenced this pull request May 9, 2014
@mattr- mattr- deleted the json-data branch May 9, 2014 17:33
@doktorbro
Copy link
Member

Love it! This feature will bring Jekyll many friends.

@doktorbro
Copy link
Member

What happens if members.json and members.yaml exist?

@parkr
Copy link
Member

parkr commented May 9, 2014

What happens if members.json and members.yaml exist?

Good point. @benbalter Could you please add a test for this?

@holic
Copy link
Contributor

holic commented May 10, 2014

Is it also worth mentioning in the docs that JSON is valid frontmatter? How about _config.json?

@mscharley
Copy link
Contributor

I don't think that JSON is valid frontmatter is it? Sure, the YAML parser
will parse it, but does it create something useful for frontmatter?

On 10 May 2014 12:22, Kevin Ingersoll notifications@github.com wrote:

Is it also worth mentioning in the docs that JSON is valid frontmatter?
How about _config.json?


Reply to this email directly or view it on GitHubhttps://github.com//pull/2369#issuecomment-42729276
.

@holic
Copy link
Contributor

holic commented May 10, 2014

Not particularly useful (YAML is easier to read/maintain), but AFAIK this:

---
layout: post
title: Some post title
---

is equivalent to this:

---
{
  "layout": "post",
  "title": "Some post title"
}
---

mattbostock added a commit to alphagov/gds-operations.github.io that referenced this pull request Jul 7, 2014
Add a Projects page which uses Jekyll's ability to read custom data from
JSON and YAML files[1] to present a list of our GitHub repositories
based on JSON data pulled from the GitHub API.

The JSON data is stored in the `_data` directory and can be updated
using the Rake task added in this commit:

```bash
bundle exec rake update_repo_data
```

Note that we use the `.yml` extension rather than `.json` because, as
of version 2.0.3, Jekyll doesn't support data files that use the .json
extension[2], even though it will interpret them if they are given a
YAML extension (presumably because YAML is a superset of JSON). We can
use `.json` once [this
issue](jekyll/jekyll#2369) is included in a
Jekyll release.

[1]: http://jekyllrb.com/docs/datafiles/
[2]: jekyll/jekyll#2441
@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants