Skip to content

Commit

Permalink
On parsha index page, more strictly display date of next read for dou…
Browse files Browse the repository at this point in the history
…bled parshiyot
  • Loading branch information
mjradwin authored Oct 1, 2024
1 parent 421c552 commit b7de642
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/sedrot.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,25 @@ export async function parshaDetail(ctx) {
const [p1] = parsha.name.split('-');
Object.assign(commentary, drash[p1]);
}
let nextRead;
if (!date) {
const today = dayjs();
for (const item of items) {
if (item.d.isAfter(today)) {
break;
} else {
nextRead = item;
}
}
}
// doubled parsha overwrites first half
Object.assign(commentary, drash[parsha.name]);
await ctx.render('parsha-detail', {
title,
parsha,
parshaName: parsha.name.replace(/'/g, '’'),
parshaAnchor,
parshaDateAnchor: getParshaDateAnchor(parshaEv).anchor,
nextRead,
reading,
il,
iSuffix,
Expand Down
4 changes: 3 additions & 1 deletion views/parsha-detail.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ ol.list-unstyled li {margin-bottom: 0.33em}
<% } -%>
<p>Parashat <%=parshaName%> is the <%=parsha.ordinal%> weekly Torah portion in the annual Jewish cycle of Torah reading.
<% if (!date) { -%>
Next read <% if (israelDiasporaDiffer) { %>in <%=locationName%><% } %> on <a href="<%=parshaDateAnchor%>"><time datetime="<%= d.format('YYYY-MM-DD') %>" class="text-nowrap"><%= d.format('D MMMM YYYY') %></time> / <span class="text-nowrap"><%= hd.toString().replace(/'/g, '') %></span></a>.
Next read <% if (israelDiasporaDiffer) { %>in <%=locationName%><% } %> on
<a href="<%=nextRead.anchor%>-<%=nextRead.d.format('YYYYMMDD')%><%=iSuffix%>"><time datetime="<%=nextRead.d.format('YYYY-MM-DD')%>"><%=nextRead.d.format('D MMM YYYY')%></time>
/ <span class="text-nowrap"><%= nextRead.event.getDate().toString().replace(/'/g, '’') %></span></a>.
<% } -%>
</p>
<% if (israelDiasporaDiffer) { -%>
Expand Down

0 comments on commit b7de642

Please sign in to comment.