-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add documentation for Data File collections. #656
Conversation
docs/quick-start.md
Outdated
@@ -211,6 +211,44 @@ collections: | |||
fields: | |||
- {label: "Language", name: "language"} | |||
``` | |||
|
|||
### Data Files |
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.
What you're describing here isn't actually specific to data files, it's actually about the files
type collection (versus the folder
type collection). Markdown files can work this way, too.
We should update this title accordingly, and have a separate section about the types of files we support (with examples). We should also move this out of quick start, I think it should all go in a new "Collections" page for now.
9d21c44
to
8530534
Compare
@erquhart How does this look? |
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.
@tech4him1 thanks so much for this! Bunch of fun change requests for you 😛
# Collections | ||
Collections define the structure for the different content types on your static site. Since every site is different, the `collections` settings will be very different from one site to the next. | ||
|
||
Let's say your site has a blog, with the posts stored in `_posts/blog`, and files saved in a date-title format, like `1999-12-31-lets-party.md`. Each post begins with settings in yaml-formatted front matter, like so: |
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.
Mix in a little more explanation that, based on the scenario, it would be best to use a folder type collection.
Also, "settings in YAML front matter".
<td>Where files of this type are stored, relative to the repo root.</td> | ||
</tr> | ||
<tr> | ||
<td><code><em>files</em></code></td> |
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.
Drop the em
tags.
</tr> | ||
<tr> | ||
<td><code>folder</code></td> | ||
<td>Where files of this type are stored, relative to the repo root.</td> |
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.
Instead: 'Indicates that this is a "folder" type collection, with every file in the folder being an instance of the collection, all sharing the same fields.' Cannot be used with the files
setting.
@@ -0,0 +1,138 @@ | |||
# Collections | |||
Collections define the structure for the different content types on your static site. Since every site is different, the `collections` settings will be very different from one site to the next. | |||
|
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.
Add a second level "Folder Type Collections" header.
- {label: "Rating (scale of 1-5)", name: "rating", widget: "number"} | ||
- {label: "Body", name: "body", widget: "markdown"} | ||
``` | ||
|
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.
Move the Files section here.
- {label: "Language", name: "language"} | ||
``` | ||
|
||
## Files |
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 to "Files Type Collections", and move below the "Folder Type Collections section", just before the table of properties.
|
||
As described above, the `widget` property specifies a built-in or custom UI widget for a given field. The first field in the example, `layout`, uses a `hidden` widget. This widget will not show in the editor UI, but will be saved with the `default` value (assuming it's been set) in the document front matter. The rest of the widgets work as follows: | ||
|
||
Widget | UI | Data Type |
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.
Instead of this table, just link to the Widgets page.
</tr> | ||
<tr> | ||
<td><code>fields</code></td> | ||
<td>Fields listed here are shown as fields in the content editor, then saved as front matter at the beginning of the document (except for <code>body</code>, which follows the front matter). Each field contains the following properties: |
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.
Append the last sentence to mention that some field/widget types have additional params, and link to the Widgets page for reference.
Based on this example, you can go through the post types in your site and add the appropriate settings to your `config.yml` file. Each post type should be listed as a separate node under the `collections` field. | ||
|
||
## Filter | ||
The entries for any collection can be filtered based on the value of a single field. The example collection, below, would only show post entries with the value "en" in the language field. |
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.
"The example collection below" (drop commas).
@@ -0,0 +1,138 @@ | |||
# Collections | |||
Collections define the structure for the different content types on your static site. Since every site is different, the `collections` settings will be very different from one site to the next. |
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.
Note that the examples below are present in the CMS repo example, and link to the relevant source.
@@ -114,103 +114,8 @@ This configuration adds a new setting, `public_folder`. While `media_folder` spe | |||
>If `public_folder` is not set, Netlify CMS will default to the same value as `media_folder`, adding an opening `/` if one is not included. | |||
|
|||
### Collections | |||
Collections define the structure for the different content types on your static site. Since every site is different, the `collections` settings will be very different from one site to the next. | |||
Collections define the structure for the different content types on your static site. They will be the main part of your config, and are explained in detail on the [Collections](collections.md) page. |
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.
@erquhart Is it good to drop everything except this from the quick-start page?
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.
Yeah, that's fine.
Thanks for creating this file! I started an outline for a Collections page within the larger docs outline in #598. I'd be curious to know what y'all think of it:
Of course, even if we agree to that outline that doesn't mean it's what the initial content here has to be. However, we also seem to be working with conflicting purposes at the moment in the docs, because I've PR'd a bunch of edits to the Quick Start that would conflict significantly here. I suggest we discuss in #598 how to break that outline up into issues that can be tackled separately without stepping on each others' work. |
@verythorough That outline looks great. Do you suggest that we just close this one for now, and incorporate it as part of your main PRs? |
I think that makes sense. I'll update the current Quick Start based on review (and to incorporate the 0.5.0 release!), then figure we merge that in as a short term solution. In the meantime, I'll break #598 into smaller, more actionable issues. I think it will make sense to talk about the role of the Quick Start in the new hierarchy. It was written under the auspices of "We don't have time for you to write full docs, so fit as much as you can into a quick tutorial." Now that we'll have full docs, I'm not even sure a tutorial will be necessary. I suppose we can discuss it further in a specific issue. :) |
Closed in favor of #598. |
- Summary
This adds documentation for how to use specific data files in a collection. Th example is copied from
/example/config.yml
.NOTE: This will need a PR on the site to add the new page before it gets merged.
- Test plan
N/A -- docs
- Description for the changelog
Add documentation for Data File collections.
- A picture of a cute animal (not mandatory but encouraged)