diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-05-02 14:58:27 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-05-02 14:58:54 -0300 |
commit | 4280c6240b88dadc8e5ea187b78c10aca9dfc163 (patch) | |
tree | 93ea9f2986fc378e7054c99f7e59c536cc2d5e20 /src/content/contracts | |
parent | bf6bff764880f96597f915bd9a59abfaaf310db1 (diff) |
contracts: initial commit
All draft stuff here for now, but this is *relatively* un-naive as it's based on a lot of recent research and discussion. But none of this code is evaluated yet!!
Diffstat (limited to 'src/content/contracts')
-rw-r--r-- | src/content/contracts/adjacentAlbumsInGroup.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/content/contracts/adjacentAlbumsInGroup.js b/src/content/contracts/adjacentAlbumsInGroup.js new file mode 100644 index 00000000..e982fa5b --- /dev/null +++ b/src/content/contracts/adjacentAlbumsInGroup.js @@ -0,0 +1,17 @@ +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}; + }, +}; |