From 43eaf804221468acaaa3cf60a30ddabae4de40b8 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 13 Aug 2024 17:56:51 -0300 Subject: content: linkAlbumDynamically: jump to #album-commentary --- .../dependencies/generateAlbumCommentaryPage.js | 1 + src/content/dependencies/linkAlbumDynamically.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index c14640af..61d9ca95 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -161,6 +161,7 @@ export default { language.encapsulate(entryCapsule, 'title.albumCommentary', titleCapsule => relations.albumCommentaryHeading.slots({ tag: 'h3', + attributes: {id: 'album-commentary'}, color: data.color, title: diff --git a/src/content/dependencies/linkAlbumDynamically.js b/src/content/dependencies/linkAlbumDynamically.js index 3adc64df..ca295b41 100644 --- a/src/content/dependencies/linkAlbumDynamically.js +++ b/src/content/dependencies/linkAlbumDynamically.js @@ -7,8 +7,24 @@ export default { infoLink: relation('linkAlbum', album), }), - generate: (relations, {pagePath}) => - (pagePath[0] === 'albumGallery' + data: (album) => ({ + albumDirectory: + album.directory, + + albumHasCommentary: + !!album.commentary, + }), + + generate: (data, relations, {pagePath}) => + (pagePath[0] === 'albumCommentary' && + pagePath[1] === data.albumDirectory && + data.albumHasCommentary + ? relations.infoLink.slots({ + anchor: true, + hash: 'album-commentary', + }) + + : pagePath[0] === 'albumGallery' ? relations.galleryLink : relations.infoLink), }; -- cgit 1.3.0-6-gf8a5