diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-05-25 08:54:29 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-05-25 08:54:29 -0300 |
commit | bd0741dcf0c23489bf710249ab8fd9ba647db843 (patch) | |
tree | 644a7cacb30aed48d49dfc44f7a91ecb14339c28 /src/content | |
parent | b11cd3418188b8c4e4c8346577f9f7577736f807 (diff) |
Revert "contracts: initial commit"
This reverts commit 4280c6240b88dadc8e5ea187b78c10aca9dfc163.
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/contracts/adjacentAlbumsInGroup.js | 17 | ||||
-rw-r--r-- | src/content/dependencies/generateAlbumSidebar.js | 46 | ||||
-rw-r--r-- | src/content/dependencies/generateAlbumSidebarGroupBox.js | 22 |
3 files changed, 21 insertions, 64 deletions
diff --git a/src/content/contracts/adjacentAlbumsInGroup.js b/src/content/contracts/adjacentAlbumsInGroup.js deleted file mode 100644 index e982fa5b..00000000 --- a/src/content/contracts/adjacentAlbumsInGroup.js +++ /dev/null @@ -1,17 +0,0 @@ -export default { - hook(contract, [album, group]) { - contract.provide({ - group, - album, - albums: contract.selectProperty(group, 'albums'), - }); - }, - - compute({group, album, albums}) { - const datedAlbums = albums.filter(album => album.date); - const index = datedAlbums.indexOf(album); - const previousAlbum = (index > 0) && datedAlbums[index - 1]; - const nextAlbum = (index < datedAlbums.length - 1) && datedAlbums[index + 1]; - return {previousAlbum, nextAlbum}; - }, -}; diff --git a/src/content/dependencies/generateAlbumSidebar.js b/src/content/dependencies/generateAlbumSidebar.js index 4eef62b2..bf6b091a 100644 --- a/src/content/dependencies/generateAlbumSidebar.js +++ b/src/content/dependencies/generateAlbumSidebar.js @@ -7,44 +7,26 @@ export default { extraDependencies: ['html'], - contracts: { - relations: { - hook(contract, [relation, album, track]) { - contract.provide({ - relation, album, track, - groups: contract.selectProperty(album, 'groups'), - trackSections: contract.selectProperty(album, 'trackSections'), - }); - }, + relations(relation, album, track) { + const relations = {}; - compute({relation, album, track, groups, trackSections}) { - const relations = {}; + relations.albumLink = + relation('linkAlbum', album); - relations.albumLink = - relation('linkAlbum', album); + relations.groupBoxes = + album.groups.map(group => + relation('generateAlbumSidebarGroupBox', album, group)); - relations.groupBoxes = - groups.map(group => - relation('generateAlbumSidebarGroupBox', album, group)); + relations.trackSections = + album.trackSections.map(trackSection => + relation('generateAlbumSidebarTrackSection', album, track, trackSection)); - relations.trackSections = - trackSections.map(trackSection => - relation('generateAlbumSidebarTrackSection', album, track, trackSection)); - - return relations; - }, - }, - - data: { - hook(contract, [album, track]) { - contract.provide({track}); - }, + return relations; + }, - compute({track}) { - return {isAlbumPage: !track}; - }, - }, + data(album, track) { + return {isAlbumPage: !track}; }, generate(data, relations, {html}) { diff --git a/src/content/dependencies/generateAlbumSidebarGroupBox.js b/src/content/dependencies/generateAlbumSidebarGroupBox.js index 4e46c931..0679e8fc 100644 --- a/src/content/dependencies/generateAlbumSidebarGroupBox.js +++ b/src/content/dependencies/generateAlbumSidebarGroupBox.js @@ -4,28 +4,20 @@ export default { contentDependencies: ['linkAlbum', 'linkExternal', 'linkGroup'], extraDependencies: ['html', 'language', 'transformMultiline'], - contracts: { - relations(contract, [album, group]) { - contract.provide({ - group, album, - - urls: contract.selectProperty(group, 'urls'), - adjacentAlbums: contract.subcontract('adjacentAlbumsInGroup', album, group), - }); - }, - }, - - relations(relation, {group, album, urls, adjacentAlbums}) { + relations(relation, album, group) { const relations = {}; relations.groupLink = relation('linkGroup', group); relations.externalLinks = - urls.map(url => - relation('linkExternal', urls)); + group.urls.map(url => + relation('linkExternal', url)); - const {previousAlbum, nextAlbum} = adjacentAlbums; + const albums = group.albums.filter(album => album.date); + const index = albums.indexOf(album); + const previousAlbum = (index > 0) && albums[index - 1]; + const nextAlbum = (index < albums.length - 1) && albums[index + 1]; if (previousAlbum) { relations.previousAlbumLink = |