From ad349c3a6949d8e6751ada62f297038336b1bcc6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 8 Apr 2024 11:44:10 -0300 Subject: content: listAllAdditionalFilesTemplate: handle empty files --- src/content/dependencies/generateListAllAdditionalFilesChunk.js | 6 ++++++ src/content/dependencies/listAllAdditionalFilesTemplate.js | 4 ++-- src/strings-default.yaml | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/content/dependencies/generateListAllAdditionalFilesChunk.js b/src/content/dependencies/generateListAllAdditionalFilesChunk.js index b046ccaf..43a78cb3 100644 --- a/src/content/dependencies/generateListAllAdditionalFilesChunk.js +++ b/src/content/dependencies/generateListAllAdditionalFilesChunk.js @@ -51,6 +51,12 @@ export default { }), })) + : additionalFileLinks.length === 0 + ? html.tag('li', + language.$('listingPage', slots.stringsKey, 'file.withNoFiles', { + title: additionalFileTitle, + })) + : html.tag('li', {class: 'has-details'}, html.tag('details', [ html.tag('summary', diff --git a/src/content/dependencies/listAllAdditionalFilesTemplate.js b/src/content/dependencies/listAllAdditionalFilesTemplate.js index bf48c966..e33ad7b5 100644 --- a/src/content/dependencies/listAllAdditionalFilesTemplate.js +++ b/src/content/dependencies/listAllAdditionalFilesTemplate.js @@ -63,7 +63,7 @@ export default { const albumAdditionalFileFiles = albumAdditionalFileObjects .map(byAlbum => byAlbum - .map(({files}) => files)); + .map(({files}) => files ?? [])); const trackAdditionalFileTitles = trackAdditionalFileObjects @@ -75,7 +75,7 @@ export default { trackAdditionalFileObjects .map(byAlbum => byAlbum .map(byTrack => byTrack - .map(({files}) => files))); + .map(({files}) => files ?? []))); return { spec, diff --git a/src/strings-default.yaml b/src/strings-default.yaml index 4d31f3bc..4b38b60d 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -1651,6 +1651,7 @@ listingPage: file: _: "{TITLE}" withMultipleFiles: "{TITLE} ({FILES})" + withNoFiles: "{TITLE} (no files)" # other.midiProjectFiles: # Same as other.allSheetMusic, but for MIDI & project files. @@ -1663,6 +1664,7 @@ listingPage: file: _: "{TITLE}" withMultipleFiles: "{TITLE} ({FILES})" + withNoFiles: "{TITLE} (no files)" # other.additionalFiles: # Same as other.allSheetMusic, but for additional files. @@ -1675,6 +1677,7 @@ listingPage: file: _: "{TITLE}" withMultipleFiles: "{TITLE} ({FILES})" + withNoFiles: "{TITLE} (no files available)" # other.randomPages: # Special listing which shows a bunch of buttons that each -- cgit 1.3.0-6-gf8a5