From bedb26b8b1054a98a820de412daf3d8b5b0dc0d6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 19 Dec 2024 12:47:48 -0400 Subject: content: linkAlbumDynamically: linkCommentaryPages slot Also some descriptions, because the dynamic behavior of this component is... pretty dynamic! --- src/content/dependencies/linkAlbumDynamically.js | 39 +++++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'src') 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), }; -- cgit 1.3.0-6-gf8a5