Path: blob/main/src/resources/projects/website/listing/item-grid.ejs.md
12923 views
<% // Fields const fields = listing.fields;
// Card alignment const align = listing["grid-item-align"] || "left";
// Borders const hideBorders = listing['grid-item-border'] === false;
// Cap Options const imgHeight = listing['image-height'];
// shorthand checks const showField = (field) => { return listing.fields.includes(field) && item[field] !== undefined; }
const readField = (item, field) => { let value = item[field]; if (field.includes(".") && !field.endsWith(".") && !field.startsWith(".")) { const fields = field.split("."); value = item; for (const deref of fields) { value = value[deref]; } } return value; }
// Capture the item number for utility functions that need it const itemNumber = listing.utilities.itemNumber();
// Fields that should be bucketized into the general listing at the bottom const otherFields = fields.filter(field => { return !["title", "image", "image-alt", "date", "author", "subtitle", "description", "filename", "file-modified", "reading-time", "categories"].includes(field); }); %>
::: {.g-col-1 <%= listing.utilities.metadataAttrs(item) %> }
<% if (fields.includes('image')) { %>
<% if (item.image) { %>
<% } else { %>
<% } %> <% } %>
<% if (showField('title') || showField('subtitle') || showField('description') || showField('author') || showField('date') || otherFields.length > 0) { %>
::: {.card-body .post-contents}
<% if (showField('title')) { %>
<%= item.title %>
<% } %><% if (showField('subtitle')) { %>
<% if (showField('reading-time')) { %>
<% } %>
<% if (fields.includes('categories') && item.categories) { %>
<% } %>
<% if (showField('description')) { %>
<%= item.description %>
<% } %>
<% const flexJustify = showField('author') && showField('date') ? "justify" : showField('author') ? "start" : "end"; %>
<% if (showField('author') || showField('date')) { %>
<% if (showField('author')) { %>
<% if (showField('date')) { %>
<% } %>
<% if (otherFields.length > 0) { %>
<% } %>
::: <% } %>
<% if (fields.includes('filename') || fields.includes('file-modified')) { %>
::: {.card-footer}
<% if (fields.includes('filename')) { %>
<% } %>
<% if (fields.includes('file-modified')) { %>
<% } %>
::: <% } %>
:::