-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Docs/sourcing from json yaml #11233
Docs/sourcing from json yaml #11233
Conversation
update gatsby remote
updating gatsby remote repo
…nd change to the side bar file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonniebigodes You should definitely fix prettier errors, besides of that LGTM 😄
Closing this pull request and removing the branch, as it seems there's no intention on merging this or anything else.....If someone more capable is will to pick it up, have fun |
Hey @jonniebigodes I’m sorry we missed this and your other PR! If you want to reopen them I’d be happy to review both of them in the morning. As you know we get a constant flow of PRs, and we try to give a timely review to all of them. Unfortunately we messed up here, I can only apologise for letting these two fall through the cracks. Finally I’d like to say thank you for all your contributions to the community, I (and the rest of the OSS team) really appreciate it. |
@m-allanson both branches and pull requests are re-opened. Feel free to provide feedback when ready. I'm going to see if i can restore the live versions back that were hosted in netlify. Or if not possible i'll update the examples readme accordingly. Sounds good? |
@jonniebigodes that sounds great, thank you! I'm working on reviews for these now. |
Thanks for opening this @jonniebigodes - I started working through it and realised we possibly need some more clarification on how best to resolve issue #11130. I've left a question for @KyleAMathews over on that issue, let's wait for an answer over there before making any further changes here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this PR! I left a bunch of comments, most of them are about the written tutorial content in its current form. It looks like there are also some files from another js-search example that could go away since this one is about JSON and YAML. Limiting the example to only the files needed to run it would be good.
To @KyleAMathews' point, there wasn't a static example already so it's great that you've added one; I think that should be included in the tutorial on its own (which focuses on single workflows, rather than presenting multiple options). See our comments here: #11130 (comment)
The appendix file would work great in the recipes section with all three examples (perhaps it gets moved into docs instead of tutorial). Here would be a good place to link to it: https://www.gatsbyjs.org/docs/recipes/#using-gatsby-without-graphql
That would mean adding an item to that section with something like "Learn how to pull data into your Gatsby site with JSON or YAML", unless you can find a way to work it into the page on "Learn how to pull unstructured data into Gatsby sites in Using Gatsby without GraphQL".
Definitely let us know if you have any questions! I'd be happy to help you move stuff around if you need assistance.
|
||
After the process is complete, some additional packages are needed. | ||
|
||
Navigate into the `gatsby-with-JSON-YAML` folder and issue the following command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd start this sentence with "Change directories" instead of "Navigate" just so that if someone doesn't know how to do it, they'll have more of a hint.
|
||
# Beforehand | ||
|
||
As you're presented with Gatsby, you'll see that you have at your disposal a myriad of ways to pull data from into your website, ranging from the most used ones like [Contenfull](https://www.contentful.com/), or [WordPress](https://wordpress.com/), [Drupal](https://www.drupal.org/), to the most edgier ones like [ButterCMS](https://buttercms.com/), [GraphCMS](https://graphcms.com/) and their appropriate plugins to ensure connectivity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Contentful
(a t
and one l
)
yarn add js-yaml uuid axios | ||
``` | ||
|
||
[Axios](https://github.com/axios/axios) will be used to handle all promise based requests, as it can be seen later. [js-yaml](https://github.com/nodeca/js-yaml) for parsing the yaml file contents. [uuid](https://github.com/kelektiv/node-uuid#readme) is used as a safety measure for React element key handling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update this to a full sentence: [js-yaml](https://github.com/nodeca/js-yaml) will parse the yaml file contents
|
||
Create a folder called `data` in the root of project folder and two more, one with the name `json` and another one called `yaml` inside that. | ||
|
||
Also another folder called `static`, as per documented [here](https://www.gatsbyjs.org/docs/static-folder/), so that the file contents can be handled more easily as you can read about later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a little folder diagram below to help illustrate the desired structure? I'm thinking something like this, but maybe there's a better syntax?
/project
/data
/json
/yaml
/static
Edit: this would change a bit for a static example pulled out on its own.
|
||
### Using JSON as a source for building a site | ||
|
||
In this section it will be presented a way to create the bare structure of a site using a JSON file and Gatsby API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this to a more active verbiage: "This section presents a way to create..."
|
||
## Routes | ||
|
||
Bellow are listed the routes generated via GATSBY API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bellow are listed the routes generated via GATSBY API | |
Below are listed the routes generated via GATSBY API |
Typo: "Below"
@@ -0,0 +1,47 @@ | |||
{ | |||
"name": "gatsby-starter-default", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package.json
file should be updated with info specific to this example. Here's another one for comparison: https://github.com/gatsbyjs/gatsby/blob/master/examples/client-only-paths/package.json
import React from 'react' | ||
|
||
const Header = ({ siteTitle }) => ( | ||
<div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this wrapper DIV to a header
element (it's a change that I also plan to make upstream in the starter):
<header
style={{
background: `rebeccapurple`,
marginBottom: `1.45rem`,
}}
>
@@ -0,0 +1,69 @@ | |||
# Logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these .gitignores and .prettierrcs can all go away in the example, it would be more consistent with the other examples: https://github.com/gatsbyjs/gatsby/tree/master/examples
@@ -0,0 +1,7 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these search example files be here? Seems like those are from another example.
@marcysutton i've read through the changes. And as their to many of them i'm going to group them into bullet points so that the draft/pull request can evolve.
|
@marcysutton while reading the comments in here and to avoid intruding in @jlengstorf out of the bat i believe that a compromise can be arranged so that the documentation can move forward.
- title: Documentation
items:
- title: Introduction
link: /docs/
- title: Quick Start
link: /docs/quick-start
- title: Recipes
link: /docs/recipes/
items:
- title: Gatsby without Graphql
link: /docs/using-gatsby-without-graphql/
- title: YAML as a source for building a site
link: /docs/sourcing-from-yaml/
- title: JSON as provider for a page
link: /docs/client-source-from-json/
- title: YAML as a provider for a page
link: /docs/client-source-from-yaml
With this it the appendix file is split into smaller more focused pieces of documentation/information. Feel free to provide feedback. Either way is fine by me, As the bulk of it is already implemented is just a matter of fine tuning |
Hi @jonniebigodes, thanks for all your thoughts and patience on this! I like your Possible Solution #2, with a few tweaks. The existing page seems like the most logical starting point, since all of these new examples are about sourcing content and data without GraphQL. To keep that page from getting too long, I think we should add two new pages under the existing one in the sidenav, using an expand toggle to hide them by default, like on the headless CMS page (if possible).
Here's an IA diagram of what I'm talking about: - title: Documentation
items:
- title: Introduction
link: /docs/
- title: Quick Start
link: /docs/quick-start
- title: Recipes
link: /docs/recipes/
items:
- title: Gatsby without Graphql
link: /docs/using-gatsby-without-graphql/
- title: YAML as a source for building a site
link: /docs/sourcing-from-yaml/
- title: Client-side sourcing with JSON or YAML
link: /docs/client-source-without-graphql/
- title: Sourcing from the Filesystem
link: /docs/sourcing-from-the-filesystem/ I picked "Client-side sourcing with JSON or YAML" and a slug of "client-source-without-graphql" to make it easier to know what that's about. I think those examples could also live on Github with Jason's example. Let me know what you think, and @jlengstorf or @DSchau as well! |
@marcysutton like i said in the previous comment, either way is perfect. Looks like one vote for the second solution, all is needed is @DSchau and @jlengstorf input and i'll adjust accordingly. |
@marcysutton going by a old wife's adage on this side of the big pond, that roughly translated means "silence means consent". As soon as my other pull request is merged, i'll adjust this one based on the evolution of the second solution mentioned and we can then proceed from here. What do you say? |
@jonniebigodes that sounds fine to me. |
Whatever @marcysutton says is good with me. :) Thanks for this, @jonniebigodes! |
Hey, @jonniebigodes — one quick note: I know you didn’t mean anything by it, but this phrasing is something we’d prefer to avoid:
Communicating intention in written text is extremely hard, so we tend to err on the side of overcautious about jokes around consent. We want to make sure everyone feels welcome in the Gatsby community, so we just steer clear of it altogether. (We talk about this a bit in our Code of Conduct, too.) Thanks again for being part of our community, and thanks in advance for keeping our community as friendly and welcoming as possible! |
@jonniebigodes mind cleaning up this PR? I'm sure everyone is pretty stoked about getting this in our docs! |
@wardpeet by the time you see this, this pull request is closed and the branch deleted. I'm cleaning up the docs and the example that goes along with it as per @marcysutton's input and also with that proceed from a "clean slate" as to avoid the file conflicts that were generated at the time, as you can see above. This piece of documentation discussed here is going to be on fresh pull request pretty soon. |
First draft of the document for sourcing from json and yaml. It documents the way to achieve this using API and fetching the data directly on the client, also provided is a working example.
Addresses #11130
Description
Related Issues