diff options
Diffstat (limited to 'src/content/dependencies/generateListingPage.js')
-rw-r--r-- | src/content/dependencies/generateListingPage.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/content/dependencies/generateListingPage.js b/src/content/dependencies/generateListingPage.js new file mode 100644 index 00000000..ae186d28 --- /dev/null +++ b/src/content/dependencies/generateListingPage.js @@ -0,0 +1,44 @@ +export default { + contentDependencies: ['generatePageLayout', 'linkListingIndex'], + extraDependencies: ['html'], + + relations(relation) { + return { + layout: relation('generatePageLayout'), + listingsIndexLink: relation('linkListingIndex'), + }; + }, + + slots: { + title: {type: 'string'}, + + type: { + validate: v => v.is('rows'), + }, + + rows: { + validate: v => v.arrayOf(v.isHTML), + }, + }, + + generate(relations, slots, {html}) { + return relations.layout.slots({ + title: slots.title, + headingMode: 'sticky', + + mainContent: [ + slots.type === 'rows' && + html.tag('ul', + slots.rows + .map(row => html.tag('li', row))), + ], + + navLinkStyle: 'hierarchical', + navLinks: [ + {auto: 'home'}, + {html: relations.listingsIndexLink}, + {auto: 'current'}, + ], + }); + }, +}; |