Merge pull request #438 from netlify/remove-example-filter

Remove example filter
This commit is contained in:
Shawn Erquhart 2017-06-01 18:30:35 -04:00 committed by GitHub
commit 50fe3b2ab1
3 changed files with 20 additions and 29 deletions

View File

@ -195,6 +195,21 @@ Widget | UI | Data Type
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. 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.
``` yaml
collections:
- name: "posts"
label: "Post"
folder: "_posts"
filter:
field: language
value: en
fields:
- {label: "Language", name: "language"}
```
## Accessing the App ## Accessing the App
With your configuration complete, it's time to try it out! Go to `yoursite.com/admin` and complete the login prompt to access the admin interface. To add users, simply add them as collaborators on the GitHub repo. With your configuration complete, it's time to try it out! Go to `yoursite.com/admin` and complete the login prompt to access the admin interface. To add users, simply add them as collaborators on the GitHub repo.

View File

@ -10,13 +10,9 @@ collections: # A list of collections the CMS should be able to edit
folder: "_posts" folder: "_posts"
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
create: true # Allow users to create new documents in this collection create: true # Allow users to create new documents in this collection
filter:
field: language
value: en
fields: # The fields each document in this collection have fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string", tagname: "h1"} - {label: "Title", name: "title", widget: "string", tagname: "h1"}
- {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"} - {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"}
- {label: "Language", name: "language", widget: "string"}
- {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""} - {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""}
- {label: "Body", name: "body", widget: "markdown"} - {label: "Body", name: "body", widget: "markdown"}
meta: meta:
@ -30,23 +26,6 @@ collections: # A list of collections the CMS should be able to edit
- {label: "Question", name: "title", widget: "string", tagname: "h1"} - {label: "Question", name: "title", widget: "string", tagname: "h1"}
- {label: "Answer", name: "body", widget: "markdown"} - {label: "Answer", name: "body", widget: "markdown"}
- name: "posts-pt" # Used in routes, ie.: /admin/collections/:slug/edit
label: "(PT) Post" # Used in the UI, ie.: "New Post"
folder: "_posts"
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
create: true # Allow users to create new documents in this collection
filter:
field: language
value: pt
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string", tagname: "h1"}
- {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"}
- {label: "Language", name: "language", widget: "string"}
- {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""}
- {label: "Body", name: "body", widget: "markdown"}
meta:
- {label: "SEO Description", name: "description", widget: "text"}
- name: "settings" - name: "settings"
label: "Settings" label: "Settings"
editor: editor:

View File

@ -11,19 +11,16 @@
window.repoFiles = { window.repoFiles = {
_posts: { _posts: {
"2015-02-14-this-is-a-post.md": { "2015-02-14-this-is-a-post.md": {
content: "---\nlanguage: en\ntitle: This is a YAML front matter post\nimage: /nf-logo.png\ndate: 2015-02-14T00:00:00.000Z\n---\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n" content: "---\ntitle: This is a YAML front matter post\nimage: /nf-logo.png\ndate: 2015-02-14T00:00:00.000Z\n---\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n"
}, },
"2015-02-15-this-is-a-json-frontmatter-post.md": { "2015-02-15-this-is-a-json-frontmatter-post.md": {
content: "{\n\"language\": \"en\",\n\"title\": \"This is a JSON front matter post\",\n\"image\": \"/nf-logo.png\",\n\"date\": \"2015-02-15T00:00:00.000Z\"\n}\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n" content: "{\n\"title\": \"This is a JSON front matter post\",\n\"image\": \"/nf-logo.png\",\n\"date\": \"2015-02-15T00:00:00.000Z\"\n}\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n"
}, },
"2015-02-16-this-is-a-toml-frontmatter-post.md": { "2015-02-16-this-is-a-toml-frontmatter-post.md": {
content: "+++\nlanguage = \"en\"\ntitle = \"This is a TOML front matter post\"\nimage = \"/nf-logo.png\"\n\"date\" = \"2015-02-16T00:00:00.000Z\"\n+++\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n" content: "+++\ntitle = \"This is a TOML front matter post\"\nimage = \"/nf-logo.png\"\n\"date\" = \"2015-02-16T00:00:00.000Z\"\n+++\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n"
}, },
"2015-02-14-this-is-a-post-with-a-different-extension.other": { "2015-02-14-this-is-a-post-with-a-different-extension.other": {
content: "---\nlanguage: en\ntitle: This post should not appear because the extension is different\nimage: /nf-logo.png\ndate: 2015-02-14T00:00:00.000Z\n---\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n" content: "---\ntitle: This post should not appear because the extension is different\nimage: /nf-logo.png\ndate: 2015-02-14T00:00:00.000Z\n---\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n"
},
"2017-05-15-this-is-a-post-with-a-different-language.pt.md": {
content: "---\nlanguage: pt\ntitle: This post should appear in a separate collection because the language is different\nimage: /nf-logo.png\ndate: 2015-02-14T00:00:00.000Z\n---\n\n# I Am a Title in Markdown\n\nHello, world\n\n* One Thing\n* Another Thing\n* A Third Thing\n"
} }
}, },
_faqs: { _faqs: {
@ -60,7 +57,7 @@
var slug = dateString + "-post-number-" + i + ".md"; var slug = dateString + "-post-number-" + i + ".md";
window.repoFiles._posts[slug] = { window.repoFiles._posts[slug] = {
content: "---\nlanguage: \"en\"\ntitle: \"This is post # " + i + "\"\ndate: " + dateString + "T00:99:99.999Z\n---\n\n# The post is number " + i + "\n\nAnd this is yet another identical post body" content: "---\ntitle: \"This is post # " + i + "\"\ndate: " + dateString + "T00:99:99.999Z\n---\n\n# The post is number " + i + "\n\nAnd this is yet another identical post body"
} }
} }