diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-10-19 21:30:05 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-02 22:25:46 -0300 |
commit | 79db317f8a6d7685114f247fe9a702320c92f26d (patch) | |
tree | 9e0565749bb5f3995fdf5e49c4f6a253edb61ed8 /src/content/dependencies/generateNewsEntryPage.js | |
parent | 047c98a6fd5f488c1d5957add8e0908c24079459 (diff) |
content: generateNewsEntryNavAccent (dots)
Diffstat (limited to 'src/content/dependencies/generateNewsEntryPage.js')
-rw-r--r-- | src/content/dependencies/generateNewsEntryPage.js | 92 |
1 files changed, 33 insertions, 59 deletions
diff --git a/src/content/dependencies/generateNewsEntryPage.js b/src/content/dependencies/generateNewsEntryPage.js index 2c382cfa..4abd87d1 100644 --- a/src/content/dependencies/generateNewsEntryPage.js +++ b/src/content/dependencies/generateNewsEntryPage.js @@ -3,10 +3,9 @@ import {atOffset} from '#sugar'; export default { contentDependencies: [ + 'generateNewsEntryNavAccent', 'generateNewsEntryReadAnotherLinks', 'generatePageLayout', - 'generatePreviousNextLinks', - 'linkNewsEntry', 'linkNewsIndex', 'transformContent', ], @@ -31,65 +30,46 @@ export default { return {previousEntry, nextEntry}; }, - relations(relation, query, sprawl, newsEntry) { - const relations = {}; + relations: (relation, query, sprawl, newsEntry) => ({ + layout: + relation('generatePageLayout'), - relations.layout = - relation('generatePageLayout'); + content: + relation('transformContent', newsEntry.content), - relations.content = - relation('transformContent', newsEntry.content); + newsIndexLink: + relation('linkNewsIndex'), - relations.newsIndexLink = - relation('linkNewsIndex'); + readAnotherLinks: + relation('generateNewsEntryReadAnotherLinks', + newsEntry, + query.previousEntry, + query.nextEntry), - relations.currentEntryLink = - relation('linkNewsEntry', newsEntry); + navAccent: + relation('generateNewsEntryNavAccent', + query.previousEntry, + query.nextEntry), + }), - if (query.previousEntry || query.nextEntry) { - relations.previousNextLinks = - relation('generatePreviousNextLinks'); + data: (query, sprawl, newsEntry) => ({ + name: newsEntry.name, + date: newsEntry.date, - relations.readAnotherLinks = - relation('generateNewsEntryReadAnotherLinks', - newsEntry, - query.previousEntry, - query.nextEntry); + daysSincePreviousEntry: + query.previousEntry && + Math.round((newsEntry.date - query.previousEntry.date) / 86400000), - if (query.previousEntry) { - relations.previousEntryNavLink = - relation('linkNewsEntry', query.previousEntry); - } + daysUntilNextEntry: + query.nextEntry && + Math.round((query.nextEntry.date - newsEntry.date) / 86400000), - if (query.nextEntry) { - relations.nextEntryNavLink = - relation('linkNewsEntry', query.nextEntry); - } - } + previousEntryDate: + query.previousEntry?.date, - return relations; - }, - - data(query, sprawl, newsEntry) { - 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, - }; - }, + nextEntryDate: + query.nextEntry?.date, + }), generate: (data, relations, {html, language}) => language.encapsulate('newsEntryPage', pageCapsule => @@ -118,13 +98,7 @@ export default { {html: relations.newsIndexLink}, { auto: 'current', - accent: - (relations.previousNextLinks - ? `(${language.formatUnitList(relations.previousNextLinks.slots({ - previousLink: relations.previousEntryNavLink ?? null, - nextLink: relations.nextEntryNavLink ?? null, - }).content)})` - : null), + accent: relations.navAccent, }, ], })), |