diff options
Diffstat (limited to 'src/content/dependencies/generateRelationsContentHeading.js')
| -rw-r--r-- | src/content/dependencies/generateRelationsContentHeading.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/content/dependencies/generateRelationsContentHeading.js b/src/content/dependencies/generateRelationsContentHeading.js new file mode 100644 index 00000000..f4fd6ad4 --- /dev/null +++ b/src/content/dependencies/generateRelationsContentHeading.js @@ -0,0 +1,40 @@ +export default { + relations: (relation, _thing) => ({ + contentHeading: + relation('generateContentHeading'), + }), + + data: (nameSlot, thing) => ({ + nameSlot, + + name: thing.name, + nameStyle: thing.nameStyle, + }), + + slots: { + attributes: {type: 'attributes', mutable: false}, + string: {type: 'string'}, + }, + + generate(data, relations, slots, {html, language}) { + const namePart = + (data.nameStyle === 'utility' || + data.nameStyle === 'unofficial' + ? null + : html.tag('i', data.name)); + + const title = + (namePart + ? language.$(slots.string, {[data.nameSlot]: namePart}) + : language.$(slots.string, 'withoutName')); + + const stickyTitle = + language.$(slots.string, 'sticky'); + + return relations.contentHeading.slots({ + attributes: slots.attributes, + title, + stickyTitle, + }); + }, +}; |