@gouvfr/dsfr-roller
Version:
Le module `dsfr-roller` permet de publier le site de documentation du Système de Design de l’État - DSFR
66 lines (58 loc) • 1.54 kB
JavaScript
import { CardContainerDirective } from '../components/card/card-container-directive.js';
class PageItemCardContainerDirective extends CardContainerDirective {
structure (data) {
const cols = {
col: data.properties?.col || 12,
colSm: data.properties?.colSm,
colMd: data.properties?.colMd,
colLg: data.properties?.colLg
}
if (!data.horizontal) {
cols.colSm = cols.colSm || 6;
cols.colLg = cols.colLg || 4;
}
data.properties = {
horizontal: data.horizontal || false,
download: data.download || false,
...cols,
...data.properties,
};
data.children = [];
if (data.noCover !== true) {
data.children.push({
type: 'image',
url: data.cover ?? '/static/img/placeholder.16x9.png',
});
}
data.children.push({
type: 'heading',
depth: 3,
children: [
{
type: 'link',
url: data.url,
children: [
{
type: 'text',
value: data.text
},
],
},
],
});
if (data.shortDescription || data.excerpt) {
data.children.push({
type: 'paragraph',
children: [
{
type: 'text',
value: data.shortDescription || data.excerpt,
},
],
});
}
return super.structure(data);
}
}
PageItemCardContainerDirective.NAME = 'dsfr-doc-page-item-card';
export { PageItemCardContainerDirective };