@druck-editorial/engine 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/frontpage.js +62 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/frontpage.js
CHANGED
|
@@ -185,6 +185,65 @@ function composeBento(rows, _opts) {
|
|
|
185
185
|
});
|
|
186
186
|
return `<div class="dfbn-head"><span class="dfbn-wm">Druck</span></div><div class="dfbn-grid">${tiles.join('')}</div>`;
|
|
187
187
|
}
|
|
188
|
+
function composeBloomberg(rows, _opts) {
|
|
189
|
+
const { lead, cells, brief } = partitionRows(rows);
|
|
190
|
+
const row = (item, isLead = false) => `<a class="dfbb-row${isLead ? ' dfbb-lead' : ''}" href="${safeHref(item)}">` +
|
|
191
|
+
`<span class="dfbb-c${isLead && item.hot ? ' dfbb-hot' : ''}">${escapeHtml(isLead && item.hot ? 'HOT' : item.category)}</span>` +
|
|
192
|
+
`<span class="dfbb-t">${escapeHtml(item.title)}</span>` +
|
|
193
|
+
`<time class="dfbb-time">${escapeHtml(item.publishedAt)}</time></a>`;
|
|
194
|
+
const parts = [
|
|
195
|
+
'<div class="dfbb-top"><span>DRUCK TERMINAL</span><span>TOP STORIES</span></div>',
|
|
196
|
+
];
|
|
197
|
+
if (lead)
|
|
198
|
+
parts.push(row(lead, true));
|
|
199
|
+
parts.push([...cells, ...brief].map((s) => row(s)).join(''));
|
|
200
|
+
return `<div class="dfbb-inner">${parts.join('')}</div>`;
|
|
201
|
+
}
|
|
202
|
+
function composeBauhaus(rows, _opts) {
|
|
203
|
+
const { lead, cells, brief } = partitionRows(rows);
|
|
204
|
+
const inner = [];
|
|
205
|
+
if (lead) {
|
|
206
|
+
inner.push(`<a class="dfbh-hero" href="${safeHref(lead)}">` +
|
|
207
|
+
`<span class="dfbh-art"><img src="${safeImg(lead)}" alt="${escapeHtml(lead.heroImageAlt ?? lead.title)}" loading="lazy" width="1200" height="800"></span>` +
|
|
208
|
+
`<span class="dfbh-plate"><span class="dfbh-k">${escapeHtml(lead.category)}</span>` +
|
|
209
|
+
`<h2>${escapeHtml(lead.title)}</h2><span class="dfbh-sub">${escapeHtml(lead.subtitle)}</span></span></a>`);
|
|
210
|
+
}
|
|
211
|
+
const stories = [...cells, ...brief];
|
|
212
|
+
if (stories.length) {
|
|
213
|
+
inner.push('<ul class="dfbh-list">' +
|
|
214
|
+
stories.map((s) => `<li><a href="${safeHref(s)}"><span class="dfbh-lk">${escapeHtml(s.category)}</span>${escapeHtml(s.title)}</a></li>`).join('') +
|
|
215
|
+
'</ul>');
|
|
216
|
+
}
|
|
217
|
+
return ('<span class="dfbh-sq"></span><span class="dfbh-circ"></span><span class="dfbh-tri"></span><span class="dfbh-bar"></span>' +
|
|
218
|
+
`<div class="dfbh-inner">${inner.join('')}</div>`);
|
|
219
|
+
}
|
|
220
|
+
function composeTabloid(rows, _opts) {
|
|
221
|
+
const { lead, cells, brief } = partitionRows(rows);
|
|
222
|
+
const parts = [
|
|
223
|
+
'<div class="dftb-mast"><span class="dftb-wm">Druck</span><span class="dftb-strap">The People's Front Page</span></div>',
|
|
224
|
+
];
|
|
225
|
+
const inner = [];
|
|
226
|
+
if (lead) {
|
|
227
|
+
inner.push(`<a class="dftb-splash" href="${safeHref(lead)}">` +
|
|
228
|
+
(lead.hasImage
|
|
229
|
+
? `<span class="dftb-art"><img src="${safeImg(lead)}" alt="${escapeHtml(lead.heroImageAlt ?? lead.title)}" loading="lazy" width="1200" height="800"></span>`
|
|
230
|
+
: '') +
|
|
231
|
+
'<span class="dftb-splash-text"><span class="dftb-k">Exclusive</span>' +
|
|
232
|
+
`<h2>${escapeHtml(lead.title)}</h2><span class="dftb-deck">${escapeHtml(lead.subtitle)}</span></span></a>`);
|
|
233
|
+
}
|
|
234
|
+
if (cells.length) {
|
|
235
|
+
inner.push('<div class="dftb-shouts">' +
|
|
236
|
+
cells.map((c) => `<a class="dftb-shout" href="${safeHref(c)}"><span class="dftb-sk">${escapeHtml(c.category)}</span><h3>${escapeHtml(c.title)}</h3></a>`).join('') +
|
|
237
|
+
'</div>');
|
|
238
|
+
}
|
|
239
|
+
if (brief.length) {
|
|
240
|
+
inner.push('<div class="dftb-more"><span class="dftb-more-label">More inside</span><ul class="dftb-list">' +
|
|
241
|
+
brief.map((b) => `<li><a href="${safeHref(b)}">${escapeHtml(b.title)}</a></li>`).join('') +
|
|
242
|
+
'</ul></div>');
|
|
243
|
+
}
|
|
244
|
+
parts.push(`<div class="dftb-inner">${inner.join('')}</div>`);
|
|
245
|
+
return parts.join('');
|
|
246
|
+
}
|
|
188
247
|
const COMPOSERS = {
|
|
189
248
|
classic: composeClassic,
|
|
190
249
|
brutalist: composeBrutalist,
|
|
@@ -192,6 +251,9 @@ const COMPOSERS = {
|
|
|
192
251
|
luxury: composeLuxury,
|
|
193
252
|
noir: composeNoir,
|
|
194
253
|
bento: composeBento,
|
|
254
|
+
bloomberg: composeBloomberg,
|
|
255
|
+
bauhaus: composeBauhaus,
|
|
256
|
+
tabloid: composeTabloid,
|
|
195
257
|
};
|
|
196
258
|
export function renderFrontPage(rows, opts) {
|
|
197
259
|
const requested = opts?.look ?? 'classic';
|
package/dist/types.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export interface WeeklySectionArticle {
|
|
|
99
99
|
image?: string;
|
|
100
100
|
summary?: string;
|
|
101
101
|
}
|
|
102
|
-
export type FrontPageLook = 'classic' | 'broadsheet' | 'brutalist' | 'luxury' | 'noir' | 'bento';
|
|
102
|
+
export type FrontPageLook = 'classic' | 'broadsheet' | 'brutalist' | 'luxury' | 'noir' | 'bento' | 'bloomberg' | 'bauhaus' | 'tabloid';
|
|
103
103
|
export interface RenderOptions {
|
|
104
104
|
lang?: string;
|
|
105
105
|
theme?: 'light' | 'dark';
|
package/package.json
CHANGED