diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-12-19 12:47:48 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-12-19 13:25:17 -0400 |
commit | bedb26b8b1054a98a820de412daf3d8b5b0dc0d6 (patch) | |
tree | a4185fe80613755e3c14996ecef67f90708df621 | |
parent | a6c2017b4d49e6e52fe3186b0d981d13414c9e0e (diff) |
content: linkAlbumDynamically: linkCommentaryPages slot
Also some descriptions, because the dynamic behavior of this component is... pretty dynamic!
-rw-r--r-- | src/content/dependencies/linkAlbumDynamically.js | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/content/dependencies/linkAlbumDynamically.js b/src/content/dependencies/linkAlbumDynamically.js index ca295b41..7173b417 100644 --- a/src/content/dependencies/linkAlbumDynamically.js +++ b/src/content/dependencies/linkAlbumDynamically.js @@ -1,10 +1,21 @@ export default { - contentDependencies: ['linkAlbumGallery', 'linkAlbum'], - extraDependencies: ['pagePath'], + contentDependencies: [ + 'linkAlbumCommentary', + 'linkAlbumGallery', + 'linkAlbum', + ], + + extraDependencies: ['html', 'pagePath'], relations: (relation, album) => ({ - galleryLink: relation('linkAlbumGallery', album), - infoLink: relation('linkAlbum', album), + galleryLink: + relation('linkAlbumGallery', album), + + infoLink: + relation('linkAlbum', album), + + commentaryLink: + relation('linkAlbumCommentary', album), }), data: (album) => ({ @@ -15,7 +26,17 @@ export default { !!album.commentary, }), - generate: (data, relations, {pagePath}) => + slots: { + linkCommentaryPages: { + type: 'boolean', + default: false, + }, + }, + + generate: (data, relations, slots, {pagePath}) => + // When linking to an album *from* an album commentary page, + // if the link is to the *same* album, then the effective target + // of the link is really the album's commentary, so scroll to it. (pagePath[0] === 'albumCommentary' && pagePath[1] === data.albumDirectory && data.albumHasCommentary @@ -24,7 +45,15 @@ export default { hash: 'album-commentary', }) + // When linking to *another* album from an album commentary page, + // the target is (by default) still just the album (its info page). + // But this can be customized per-link! + : pagePath[0] === 'albumCommentary' && + slots.linkCommentaryPages + ? relations.commentaryLink + : pagePath[0] === 'albumGallery' ? relations.galleryLink + : relations.infoLink), }; |