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

Exposes _data/team.yml as publicly accessible JSON #296

Merged
merged 8 commits into from
Oct 16, 2014

Conversation

gboone
Copy link
Contributor

@gboone gboone commented Oct 8, 2014

I'm not sure if this will actually work (it should but my localhost webrick server was serving the generated file with Content-Type: text/html instead of application/JSON) but this would expose the team member data we have in _data as an api endpoint and allow us to access it in any of our other projects (like dashboard) as well as in javascript on the front end.

Leaving this here for discussion.

@konklone
Copy link
Contributor

konklone commented Oct 8, 2014

Love this idea, let's do it. I think it'd be better to use Jekyll's built in jsonify filter though:

jsonify

@gbinal
Copy link
Member

gbinal commented Oct 8, 2014

+100

Please make sure we mention this on our /developer page.

@gboone
Copy link
Contributor Author

gboone commented Oct 9, 2014

Thanks for the tip on the jsonify filter, @konklone, I'd forgotten about that. 👍
@gbinal: Will do, thinking about doing the same for our blog posts too with JekyllBot.

@konklone
Copy link
Contributor

konklone commented Oct 9, 2014

@gbinal: Will do, thinking about doing the same for our blog posts too with JekyllBot.

Now that's interesting. Looks like JekyllBot is abandoned, though. I bet we could create a pretty simple JSON content API ourselves with today's Jekyll, or through a Jekyll plugin?

@konklone konklone mentioned this pull request Oct 9, 2014
@konklone
Copy link
Contributor

@gboone is this good to go?

@gboone
Copy link
Contributor Author

gboone commented Oct 14, 2014

Well, it is in that it works (it generates something) but it generates an HTML file that has JSON in it. So, I don't think so, no.

Greg Boone added 4 commits October 15, 2014 14:53
Previous solutions have created json by using a page template. That's fine
but actually generates an html file with json in the body. In addition to
sending the data with the wrong content-type it also is rendered as html by
browsers, javascript, etc., and would have required more maintenance for
new data sets.

This commit exposes an endpoint at `/api/<data>.json` for every dataset in
the _data directory. For example, this site will have _data/team.yml
exposed at `/api/team.json`
@gboone
Copy link
Contributor Author

gboone commented Oct 16, 2014

This should work now. Testing it locally I get valid JSON with the correct headers at /data/team.json

meiqimichelle added a commit that referenced this pull request Oct 16, 2014
Exposes _data/team.yml as publicly accessible JSON
@meiqimichelle meiqimichelle merged commit 3e91e7a into staging Oct 16, 2014
@konklone konklone deleted the team-members-api branch October 16, 2014 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants