diff --git a/src/parshaCommon.js b/src/parshaCommon.js index 3335626..71fe2c3 100644 --- a/src/parshaCommon.js +++ b/src/parshaCommon.js @@ -150,7 +150,7 @@ export function lookupParshaMeta(parshaName) { name: parshaName, bookName: torahBookNames[parsha0.book - 1], anchor: makeAnchor(parshaName), - verses: parsha0.fullkriyah['1'][0] + '-' + parsha0.fullkriyah['7'][1], + verses: parshaVerses(parsha0), ...parsha0, }; if (parsha.combined) { @@ -164,6 +164,8 @@ export function lookupParshaMeta(parshaName) { parsha.p2anchor = makeAnchor(p2); const haftKey = p1 === 'Nitzavim' ? p1 : p2; parsha.haft = lookupParsha(haftKey).haft; + const p1meta = lookupParsha(p1); + parsha.p1verses = parshaVerses(p1meta); } else { parsha.ordinal = Locale.ordinal(parsha.num, 'en'); } @@ -178,6 +180,11 @@ export function lookupParshaMeta(parshaName) { return parsha; } +function parshaVerses(parshaMeta) { + const fk = parshaMeta.fullkriyah; + return fk['1'][0] + '-' + fk['7'][1]; +} + /** * @param {any} parsha * @return {any} diff --git a/src/sedrot.js b/src/sedrot.js index 03bf9cc..316c67b 100644 --- a/src/sedrot.js +++ b/src/sedrot.js @@ -341,9 +341,25 @@ function doIsraelDiasporaDiffer(parsha, il, hd, triennial) { return [false, '', '']; } +/** @return {number} */ +function nextParshaNum(parsha) { + if (parsha.num === 54) { + return 0; + } + return parsha.combined ? parshaNum.get(parsha.p2) : parsha.num; +} + +/** @return {number} */ +function prevParshaNum(parsha) { + if (parsha.num === 1) { + return 53; + } + return parsha.combined ? parshaNum.get(parsha.p1) - 2 : parsha.num - 2; +} + function makePrevNext(parsha, date, hd, il) { - const prevNum = parsha.num === 1 ? 53 : parsha.combined ? parshaNum.get(parsha.p1) - 2 : parsha.num - 2; - const nextNum = parsha.num === 54 ? 0 : parsha.combined ? parshaNum.get(parsha.p2) : parsha.num; + const prevNum = prevParshaNum(parsha); + const nextNum = nextParshaNum(parsha); const prevName = parshiot54[prevNum]; const nextName = parshiot54[nextNum]; if (date) { diff --git a/views/parsha-detail.ejs b/views/parsha-detail.ejs index 69b3c21..d1f9fa8 100644 --- a/views/parsha-detail.ejs +++ b/views/parsha-detail.ejs @@ -207,7 +207,7 @@ Some congregations read the entire parsha every year (“Option A”). <% if (commentary['asin']) { - const altText = parsha.p1||parshaName + ': The JPS B’nai Mitzvah Torah Commentary (JPS Study Bible)'; + const altText = (parsha.p1||parshaName) + ': The JPS B’nai Mitzvah Torah Commentary (JPS Study Bible)'; %>