diff options
Diffstat (limited to 'src/content')
5 files changed, 38 insertions, 73 deletions
diff --git a/src/content/dependencies/generateAlbumCoverArtwork.js b/src/content/dependencies/generateAlbumCoverArtwork.js index f6583882..d52d57ce 100644 --- a/src/content/dependencies/generateAlbumCoverArtwork.js +++ b/src/content/dependencies/generateAlbumCoverArtwork.js @@ -34,6 +34,8 @@ export default { }), slots: { + mode: {type: 'string'}, + details: { validate: v => v.is('tags', 'artists'), default: 'tags', @@ -42,6 +44,8 @@ export default { generate: (data, relations, slots, {language}) => relations.coverArtwork.slots({ + mode: slots.mode, + image: relations.image.slots({ path: data.path, diff --git a/src/content/dependencies/generateCoverArtwork.js b/src/content/dependencies/generateCoverArtwork.js index 50089f69..27133b9d 100644 --- a/src/content/dependencies/generateCoverArtwork.js +++ b/src/content/dependencies/generateCoverArtwork.js @@ -34,25 +34,31 @@ export default { ? {square: true} : {dimensions: slots.dimensions}); - return html.tags([ - (slots.mode === 'primary' - ? slots.image.slots({ + switch (slots.mode) { + case 'primary': + return html.tags([ + slots.image.slots({ thumb: 'medium', reveal: true, link: true, ...sizeSlots, - }) + }), - : slots.mode === 'thumbnail' - ? slots.image.slots({ + slots.details, + ]); + + case 'thumbnail': + return ( + slots.image.slots({ thumb: 'small', reveal: false, link: false, ...sizeSlots, - }) + })); - : slots.mode === 'commentary' - ? slots.image.slots({ + case 'commentary': + return ( + slots.image.slots({ thumb: 'medium', reveal: true, link: true, @@ -61,11 +67,10 @@ export default { attributes: {class: 'commentary-art'}, - }) - - : html.blank()), + })); - html.tags([slots.details], {[html.onlyIfSiblings]: true}), - ]); + default: + return html.blank(); + } }, }; diff --git a/src/content/dependencies/generateFlashCoverArtwork.js b/src/content/dependencies/generateFlashCoverArtwork.js index 02590a09..a9fbde38 100644 --- a/src/content/dependencies/generateFlashCoverArtwork.js +++ b/src/content/dependencies/generateFlashCoverArtwork.js @@ -1,6 +1,6 @@ export default { contentDependencies: ['generateCoverArtwork'], - extraDependencies: ['language'], + extraDependencies: ['html', 'language'], relations: (relation) => ({ coverArtwork: @@ -21,8 +21,14 @@ export default { flash.coverArtDimensions, }), - generate: (data, relations, {language}) => + slots: { + mode: {type: 'string'}, + }, + + generate: (data, relations, slots, {language}) => relations.coverArtwork.slots({ + mode: slots.mode, + image: relations.image.slots({ data: data.path, diff --git a/src/content/dependencies/generateStickyHeadingContainer.js b/src/content/dependencies/generateStickyHeadingContainer.js index ab607a4f..7cfbcf50 100644 --- a/src/content/dependencies/generateStickyHeadingContainer.js +++ b/src/content/dependencies/generateStickyHeadingContainer.js @@ -28,63 +28,9 @@ export default { html.tag('div', {class: 'content-sticky-heading-cover'}, {[html.onlyIfContent]: true}, - (() => { - if (html.isBlank(slots.cover)) { - return html.blank(); - } - - // Try very hard to set the cover's 'mode' slot to 'thumbnail' - // and its 'details' slot to html.blank(). - let setMode = false; - let setDetails = false; - let cover = slots.cover; - while (true) { - if (!cover) { - return html.blank(); - } - - if (!(cover instanceof html.Template)) { - return cover; - } - - // The cover from `slots` is already cloned (since it's - // mutable), but later ones are not, and for extremely scary - // content function infrastructure reasons, it is possible - // for the identity of the content of the clone-template - // to be the same as the cloned template. - if (cover !== slots.cover) { - cover = cover.clone(); - } - - if (!setMode) { - try { - cover.setSlot('mode', 'thumbnail'); - setMode = true; - } catch { - // No mode slot, or it doesn't allow 'thumbnail'. - } - } - - if (!setDetails) { - try { - cover.setSlot('details', html.blank()); - setDetails = true; - } catch { - // No details slot, or it doesn't allow html.blank(). - // We're setting a blank instead of null because null is - // always allowed, and can carry a different semantic - // meaning, like "put something else here by default - // instead please". - } - } - - if (setMode && setDetails) { - return cover; - } - - cover = cover.content; - } - })())), + (html.isBlank(slots.cover) + ? html.blank() + : slots.cover.slot('mode', 'thumbnail')))), ]), html.tag('div', {class: 'content-sticky-subheading-row'}, diff --git a/src/content/dependencies/generateTrackCoverArtwork.js b/src/content/dependencies/generateTrackCoverArtwork.js index f75bf00b..2ad14993 100644 --- a/src/content/dependencies/generateTrackCoverArtwork.js +++ b/src/content/dependencies/generateTrackCoverArtwork.js @@ -44,6 +44,8 @@ export default { }), slots: { + mode: {type: 'string'}, + details: { validate: v => v.is('tags', 'artists'), default: 'tags', @@ -52,6 +54,8 @@ export default { generate: (data, relations, slots, {language}) => relations.coverArtwork.slots({ + mode: slots.mode, + image: relations.image.slots({ path: data.path, |