* A bunch of shorthand to put together common parts of an HTML page.
*/
-const { lazy } = require('@squeep/lazy');
+const { lazy } = require('@squeep/lazy-property');
/**
* Some fields may have values outside normal dates, handle them here.
});
+/**
+ * Wrap a Date in a <time> block.
+ * @param {Date} date
+ * @param {Object} options
+ * @param {String=} options.title
+ */
+const timeElement = (date, options = {}) => {
+ const {
+ title,
+ pInf,
+ nInf,
+ otherwise,
+ } = options;
+ const attributes = {
+ ...(title && { title }),
+ ...(date instanceof Date && { datetime: date.toISOString() }),
+ };
+ return [
+ '<time',
+ elementAttributes(attributes),
+ '>',
+ dateFormat(date, pInf, nInf, otherwise),
+ '</time>',
+ ].join('');
+}
+
+
/**
* Render a duration.
* @param {Number} seconds
};
+/**
+ * Return array of strings prefixed with tabs.
+ * @param {Number} indent
+ * @param {String[]} list
+ */
+const indented = (indent, list) => {
+ const spacer = '\t'.repeat(indent);
+ return list.map((l) => `${spacer}${l}`);
+};
+
+
/**
* Render the preamble <head> for an HTML page.
* @param {Number} pagePathLevel number of paths below root this page is
module.exports = {
dateOrNot,
dateFormat,
+ timeElement,
secondsToPeriod,
htmlHead,
htmlBody,
htmlHeader,
htmlFooter,
htmlMessages,
+ indented,
renderNavLink,
LI,
UL,