diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-08-13 17:56:51 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-08-13 17:56:51 -0300 |
commit | 43eaf804221468acaaa3cf60a30ddabae4de40b8 (patch) | |
tree | 2574cddd0518e892e0e9554828353412c1f568c9 /src | |
parent | f1948a85f54260c8b15da61a362d63bec6f00926 (diff) |
content: linkAlbumDynamically: jump to #album-commentary
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/generateAlbumCommentaryPage.js | 1 | ||||
-rw-r--r-- | src/content/dependencies/linkAlbumDynamically.js | 20 | ||||
-rw-r--r-- | src/util/replacer.js | 2 |
3 files changed, 20 insertions, 3 deletions
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), }; diff --git a/src/util/replacer.js b/src/util/replacer.js index d1b0a269..9034cb9d 100644 --- a/src/util/replacer.js +++ b/src/util/replacer.js @@ -13,7 +13,7 @@ import {escapeRegex, typeAppearance} from '#sugar'; export const replacerSpec = { 'album': { find: 'album', - link: 'linkAlbum', + link: 'linkAlbumDynamically', }, 'album-commentary': { |