2023-11-08 22:06:07 +00:00
|
|
|
/* eslint-disable indent, quotes */
|
|
|
|
// eslint-disable-next-line spaced-comment
|
|
|
|
/// <reference path="./codex.ts" />
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Object} options
|
|
|
|
* @param {string} options.heading
|
|
|
|
* @param {boolean} options.isContainerSmall
|
|
|
|
* @param {Codex.ListTitleObject[]} options.cards
|
|
|
|
* @return {string}
|
|
|
|
*/
|
2024-06-14 12:07:36 +00:00
|
|
|
const RelatedArticles = ( options ) => [
|
2024-04-20 20:15:07 +00:00
|
|
|
`<div class="read-more-container ${ ( options.isContainerSmall ) ? 'read-more-container-small' : 'read-more-container-large' }">`,
|
2023-11-08 22:06:07 +00:00
|
|
|
`<aside class="noprint">`,
|
|
|
|
( options.heading ) ?
|
2024-04-20 20:15:07 +00:00
|
|
|
`<h2 class="read-more-container-heading">${ options.heading }</h2>` : ``,
|
2023-11-08 22:06:07 +00:00
|
|
|
`<ul class="read-more-container-card-list">`,
|
2024-04-20 20:15:07 +00:00
|
|
|
options.cards.map( ( card ) => `<li title="${ card.label }">
|
|
|
|
<a href="${ card.url }"><span class="cdx-card">
|
2023-11-08 22:06:07 +00:00
|
|
|
<span class="cdx-card__thumbnail cdx-thumbnail">
|
2024-04-20 20:15:07 +00:00
|
|
|
${ ( card.thumbnail && card.thumbnail.url ) ?
|
|
|
|
`<span class="cdx-thumbnail__image" style="background-image: url('${ card.thumbnail.url }')"></span>` :
|
2023-11-08 22:06:07 +00:00
|
|
|
`<span class="cdx-thumbnail__placeholder">
|
|
|
|
<span class="cdx-thumbnail__placeholder__icon"></span>
|
2024-04-20 20:15:07 +00:00
|
|
|
</span>` }
|
2023-11-08 22:06:07 +00:00
|
|
|
</span>
|
|
|
|
<span class="cdx-card__text">
|
2024-04-20 20:15:07 +00:00
|
|
|
<span class="cdx-card__text__title">${ card.label }</span>
|
|
|
|
<span class="cdx-card__text__description">${ card.description }</span>
|
2023-11-08 22:06:07 +00:00
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</li>` ).join( '\n' ),
|
|
|
|
`</ul>`,
|
|
|
|
`</aside>`,
|
|
|
|
`</div>`
|
|
|
|
].join( '\n' );
|
|
|
|
|
|
|
|
module.exports = RelatedArticles;
|