From a1d39a16ab3ed60a9af4ef277fbf5c4a98a84b2d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 1 May 2026 18:37:35 -0300 Subject: content: generateListenLineOrList, generateReleaseInfoBlock --- .../dependencies/generateReleaseInfoBlock.js | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/content/dependencies/generateReleaseInfoBlock.js (limited to 'src/content/dependencies/generateReleaseInfoBlock.js') diff --git a/src/content/dependencies/generateReleaseInfoBlock.js b/src/content/dependencies/generateReleaseInfoBlock.js new file mode 100644 index 00000000..93d889ab --- /dev/null +++ b/src/content/dependencies/generateReleaseInfoBlock.js @@ -0,0 +1,64 @@ +import {empty} from '#sugar'; + +export default { + slots: { + // This isn't mutable, but we will be inspecting items' contents. + items: {validate: v => v.looseArrayOf(v.isHTML)}, + }, + + generate(slots, {html}) { + const tags = []; + + let paragraphLines = []; + const closeParagraph = () => { + if (empty(paragraphLines)) return; + + const paragraph = + html.tag('p', + {[html.joinChildren]: html.tag('br')}, + {[html.onlyIfContent]: true}, + paragraphLines); + + tags.push(paragraph); + paragraphLines = []; + }; + + for (let item of slots.items) { + item = html.Template.resolve(item); + + if (typeof item === 'string' && item.length) { + paragraphLines.push(item); + continue; + } + + if (html.isBlank(item)) { + continue; + } + + if (item.contentOnly) { + paragraphLines.push(item); + continue; + } + + if (item.tagName === 'br') { + continue; + } + + if (item.tagName === 'p') { + paragraphLines.push(item.content); + continue; + } + + closeParagraph(); + tags.push(item); + } + + closeParagraph(); + + if (empty(tags)) { + return html.blank(); + } else { + return html.tags(tags); + } + } +}; -- cgit 1.3.0-6-gf8a5