add jsdoc

This commit is contained in:
2026-04-17 15:36:11 +02:00
parent 8d1a6ba740
commit 46c34ba545
3 changed files with 32 additions and 3 deletions
+22 -3
View File
@@ -1,13 +1,19 @@
import { format } from "date-fns";
import Handlebars from "handlebars";
import romcal from "romcal";
import { isToday } from "date-fns";
import { isToday, startOfToday, getYear } from "date-fns";
/**
* Generates CSS styles for the HTML content, dynamically adjusting colors based on the current liturgical event.
*
* @returns {string} A string containing the CSS styles.
*/
function css() {
let color = "#007acc"; // Default color
// Get today's liturgical event from the Roman calendar
const event = romcal
.calendarFor(new Date().getFullYear())
.calendarFor(getYear(startOfToday()))
.find((e) => isToday(new Date(e.moment)));
if (event) {
@@ -81,8 +87,15 @@ const readingTemplate = Handlebars.compile(`
</html>
`);
/**
* Generates the HTML content for the daily Bible reading, including the title, readings, and a link to the source.
*
* @param {string} title - The title of the reading.
* @param {Array} readings - An array of reading objects, each containing a title, content, and URL.
* @returns {string} A string containing the generated HTML content for the reading.
*/
export function reading(title, readings) {
const now = new Date();
const now = startOfToday();
const url = `https://bible.usccb.org/bible/readings/${format(now, "MMddyy")}.cfm`;
const date = format(now, "MMMM d, yyyy");
@@ -94,6 +107,12 @@ export function reading(title, readings) {
});
}
/**
* Generates the HTML content for an error message when fetching the reading fails.
*
* @param {number} status - The HTTP status code of the error.
* @returns {string} A string containing the generated HTML content for the error message.
*/
export function error(status) {
return `
<html>