diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/generateAlbumReleaseInfo.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/content/dependencies/generateAlbumReleaseInfo.js b/src/content/dependencies/generateAlbumReleaseInfo.js index 1cd638ce..26e2e160 100644 --- a/src/content/dependencies/generateAlbumReleaseInfo.js +++ b/src/content/dependencies/generateAlbumReleaseInfo.js @@ -1,4 +1,4 @@ -import {accumulateSum} from '#sugar'; +import {accumulateSum, empty} from '#sugar'; export default { contentDependencies: [ @@ -41,8 +41,18 @@ export default { data.coverArtDate = album.coverArtDate; } - data.duration = accumulateSum(album.tracks, track => track.duration); - data.durationApproximate = album.tracks.length > 1; + const durationTerms = + album.tracks + .map(track => track.duration) + .filter(value => value > 0); + + if (empty(durationTerms)) { + data.duration = null; + data.durationApproximate = null; + } else { + data.duration = accumulateSum(durationTerms); + data.durationApproximate = album.tracks.length > 1; + } data.numTracks = album.tracks.length; |