mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-12-19 03:20:44 +00:00
fddb47b128
Change-Id: I6f9731d42bceb5ff4e2c9733a567c72e359abcbd
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
/* 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}
|
|
*/
|
|
const RelatedArticles = ( options ) => [
|
|
`<div class="read-more-container ${ ( options.isContainerSmall ) ? 'read-more-container-small' : 'read-more-container-large' }">`,
|
|
`<aside class="noprint">`,
|
|
( options.heading ) ?
|
|
`<h2 class="read-more-container-heading">${ options.heading }</h2>` : ``,
|
|
`<ul class="read-more-container-card-list">`,
|
|
options.cards.map( ( card ) => `<li title="${ card.label }">
|
|
<a href="${ card.url }"><span class="cdx-card">
|
|
<span class="cdx-card__thumbnail cdx-thumbnail">
|
|
${ ( card.thumbnail && card.thumbnail.url ) ?
|
|
`<span class="cdx-thumbnail__image" style="background-image: url('${ card.thumbnail.url }')"></span>` :
|
|
`<span class="cdx-thumbnail__placeholder">
|
|
<span class="cdx-thumbnail__placeholder__icon"></span>
|
|
</span>` }
|
|
</span>
|
|
<span class="cdx-card__text">
|
|
<span class="cdx-card__text__title">${ card.label }</span>
|
|
<span class="cdx-card__text__description">${ card.description }</span>
|
|
</span>
|
|
</a>
|
|
</li>` ).join( '\n' ),
|
|
`</ul>`,
|
|
`</aside>`,
|
|
`</div>`
|
|
].join( '\n' );
|
|
|
|
module.exports = RelatedArticles;
|