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

Add documentation for Data File collections. #656

Closed
wants to merge 1 commit into from

Conversation

tech4him1
Copy link
Contributor

@tech4him1 tech4him1 commented Oct 5, 2017

- 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)

@@ -211,6 +211,44 @@ collections:
fields:
- {label: "Language", name: "language"}
```

### Data Files
Copy link
Contributor

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.

@tech4him1
Copy link
Contributor Author

@erquhart How does this look?

Copy link
Contributor

@erquhart erquhart left a 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:
Copy link
Contributor

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>
Copy link
Contributor

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>
Copy link
Contributor

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.

Copy link
Contributor

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"}
```

Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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:
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's fine.

@verythorough
Copy link
Contributor

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:

  • Collections: file, folder, filter
    (explain the differences, show config examples for each)
    • file:
      • single file or grouping of files, with fields specified for each file individually
      • can be useful for data files with settings or highly customized pages
      • cannot be filtered; cannot add new items
    • folder:
      • grouping of separate files based on the same template, stored in the same folder
      • UI field will be identical for all items in the folder (or all matching the filter)
      • may or may not be able to add new items (depending on create field)
    • filter:
      • used with folder type
      • can be used to pull only items matching the specified field value
      • requires field and value: must be an exact match
    • Note: regardless of collection type, each item in the main area of the collection browser represents a separate file (though separate files may be combined into a single published page via templating)

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.

@tech4him1
Copy link
Contributor Author

@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?

@verythorough
Copy link
Contributor

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. :)

@tech4him1
Copy link
Contributor Author

Closed in favor of #598.

@tech4him1 tech4him1 closed this Oct 6, 2017
@tech4him1 tech4him1 deleted the data-file-docs branch December 12, 2017 02:25
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.

3 participants