diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-11-08 19:58:44 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-11-08 19:58:44 -0400 |
commit | 213bddbd9851ee01f256835b1bca0c4bc0cf5fc6 (patch) | |
tree | 9623cd248df3b893d2831f08cfddf1d40db03e93 /src/content/dependencies | |
parent | b62622d3cd8ffe1ed517ceb873d9352943c4a601 (diff) |
content: generateNewsEntryPage: read next/previous links at end
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateNewsEntryPage.js | 66 |
1 files changed, 62 insertions, 4 deletions
diff --git a/src/content/dependencies/generateNewsEntryPage.js b/src/content/dependencies/generateNewsEntryPage.js index 62d6bb7b..c8db9f35 100644 --- a/src/content/dependencies/generateNewsEntryPage.js +++ b/src/content/dependencies/generateNewsEntryPage.js @@ -53,12 +53,18 @@ export default { relation('generatePreviousNextLinks'); if (query.previousEntry) { - relations.previousEntryLink = + relations.previousEntryNavLink = + relation('linkNewsEntry', query.previousEntry); + + relations.previousEntryContentLink = relation('linkNewsEntry', query.previousEntry); } if (query.nextEntry) { - relations.nextEntryLink = + relations.nextEntryNavLink = + relation('linkNewsEntry', query.nextEntry); + + relations.nextEntryContentLink = relation('linkNewsEntry', query.nextEntry); } } @@ -70,6 +76,20 @@ export default { return { name: newsEntry.name, date: newsEntry.date, + + daysSincePreviousEntry: + query.previousEntry && + Math.round((newsEntry.date - query.previousEntry.date) / 86400000), + + daysUntilNextEntry: + query.nextEntry && + Math.round((query.nextEntry.date - newsEntry.date) / 86400000), + + previousEntryDate: + query.previousEntry?.date, + + nextEntryDate: + query.nextEntry?.date, }; }, @@ -90,6 +110,44 @@ export default { })), relations.content, + + html.tag('p', { + [html.onlyIfContent]: true, + [html.joinChildren]: html.tag('br'), + class: 'read-another-links', + }, [ + relations.previousEntryContentLink && + language.$('newsEntryPage.readAnother.previous', { + entry: relations.previousEntryContentLink, + + date: + html.tag('span', + { + title: + language.$('newsEntryPage.readAnother.earlier', { + time: + language.countDays(data.daysSincePreviousEntry, {unit: true}), + }).toString(), + }, + language.formatDate(data.previousEntryDate)), + }), + + relations.nextEntryContentLink && + language.$('newsEntryPage.readAnother.next', { + entry: relations.nextEntryContentLink, + + date: + html.tag('span', + { + title: + language.$('newsEntryPage.readAnother.later', { + time: + language.countDays(data.daysUntilNextEntry, {unit: true}), + }).toString(), + }, + language.formatDate(data.nextEntryDate)), + }), + ]), ], navLinkStyle: 'hierarchical', @@ -101,8 +159,8 @@ export default { accent: (relations.previousNextLinks ? `(${language.formatUnitList(relations.previousNextLinks.slots({ - previousLink: relations.previousEntryLink ?? null, - nextLink: relations.nextEntryLink ?? null, + previousLink: relations.previousEntryNavLink ?? null, + nextLink: relations.nextEntryNavLink ?? null, }).content)})` : null), }, |