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 getCollection prop #55

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion content/docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Registers a template for a folder collection or an individual file in a file col
* name: The name of the collection (or file for file collections) which this preview component will be used for.
* Folder collections: Use the name of the collection
* File collections: Use the name of the file
* react_component: A React component that renders the collection data. Six props will be passed to your component during render:
* react_component: A React component that renders the collection data. Seven props will be passed to your component during render:
* entry: Immutable collection containing the entry data.
* widgetFor: Returns the appropriate widget preview component for a given field.
* [widgetsFor](#lists-and-objects): Returns an array of objects with widgets and associated field data. For use with list and object type entries.
Expand All @@ -102,6 +102,29 @@ Registers a template for a folder collection or an individual file in a file col
CMS.registerPreviewTemplate("posts", PostPreview);
</script>
```
* getCollection: Returns a promise that resolves with the entries in a collection
**Params:**
* collection: The name of the collection - required
* slug: The slug of the entry - optional: if not supplied all entries will be returned

**Example:**
```html
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
<script>
var PostPreview = createClass({
render: function() {
var posts = await getCollection('posts');
var arr = [];
posts.forEach((t) => {
const getingData = t.get('data');
console.log(getingData);
});
return null;
}
});

CMS.registerPreviewTemplate("posts", PostPreview);
</script>
* document: The preview pane iframe's [document instance](https://github.com/ryanseddon/react-frame-component/tree/9f8f06e1d3fc40da7122f0a57c62f7dec306e6cb#accessing-the-iframes-window-and-document).
* window: The preview pane iframe's [window instance](https://github.com/ryanseddon/react-frame-component/tree/9f8f06e1d3fc40da7122f0a57c62f7dec306e6cb#accessing-the-iframes-window-and-document).

Expand Down