Skip to content

Commit 8dcec03

Browse files
committed
feat(Collection): Passing the index to collection template
1 parent 8ec3e09 commit 8dcec03

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import {Collection} from '@quintype/components'
6565

6666
// collection = Collection.getCollectionBySlug(client, 'home', {}, {depth: 1})
6767

68-
function TwoColLayout({collection, associatedMetadata}) {
68+
function TwoColLayout({collection, associatedMetadata, index}) {
6969
// for item in collection.item
7070
// if item.type == story
7171
// showStory

src/components/collection.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ function renderCollectionItem(collectionItem, index, collectionTemplates, storyT
1616
case "collection":
1717
return React.createElement(collectionTemplates(getAssociatedTemplate(collectionItem), index), {
1818
key: `${index}-${collectionItem.id}`,
19+
index: index,
1920
collection: collectionItem,
2021
metadata: collectionItem["associated-metadata"] || {}
2122
});
2223

2324
case "story":
2425
return React.createElement(storyTemplates(index), {
2526
key: `${index}-${collectionItem.id}`,
27+
index: index,
2628
story: collectionItem.story,
2729
metadata: collectionItem["associated-metadata"] || {}
2830
});

0 commit comments

Comments
 (0)