« get me outta code hell

tagification album commentary progress - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-06-28 09:07:23 -0300
committer(quasar) nebula <qznebula@protonmail.com>2022-06-28 09:07:23 -0300
commit88c0d66fbb00a14fb2a40b05a89f16f3bec52ec0 (patch)
treed9d716f3b385d2b025b4fd8dcf6def4a95d05a06 /src/page
parent08b700bb14e5e12c1dff283e2eef729816a97f15 (diff)
tagification album commentary progress
Diffstat (limited to 'src/page')
-rw-r--r--src/page/album-commentary.js128
1 files changed, 38 insertions, 90 deletions
diff --git a/src/page/album-commentary.js b/src/page/album-commentary.js
index 255a6584..43b8c8d6 100644
--- a/src/page/album-commentary.js
+++ b/src/page/album-commentary.js
@@ -4,8 +4,7 @@
 
 // Imports
 
-import fixWS from 'fix-whitespace';
-
+import * as html from '../util/html.js';
 import {filterAlbumsByCommentary} from '../util/wiki-data.js';
 
 // Page exports
@@ -40,53 +39,29 @@ export function write(album) {
       theme: getThemeString(album.color),
 
       main: {
-        content: fixWS`
-                    <div class="long-content">
-                        <h1>${language.$('albumCommentaryPage.title', {
-                          album: link.album(album),
-                        })}</h1>
-                        <p>${language.$('albumCommentaryPage.infoLine', {
-                          words: `<b>${language.formatWordCount(words, {
-                            unit: true,
-                          })}</b>`,
-                          entries: `<b>${language.countCommentaryEntries(
-                            entries.length,
-                            {
-                              unit: true,
-                            }
-                          )}</b>`,
-                        })}</p>
-                        ${
-                          album.commentary &&
-                          fixWS`
-                            <h3>${language.$(
-                              'albumCommentaryPage.entry.title.albumCommentary'
-                            )}</h3>
-                            <blockquote>
-                                ${transformMultiline(album.commentary)}
-                            </blockquote>
-                        `
-                        }
-                        ${album.tracks
-                          .filter((t) => t.commentary)
-                          .map(
-                            (track) => fixWS`
-                            <h3 id="${track.directory}">${language.$(
-                              'albumCommentaryPage.entry.title.trackCommentary',
-                              {
-                                track: link.track(track),
-                              }
-                            )}</h3>
-                            <blockquote style="${getLinkThemeString(
-                              track.color
-                            )}">
-                                ${transformMultiline(track.commentary)}
-                            </blockquote>
-                        `
-                          )
-                          .join('\n')}
-                    </div>
-                `,
+        content: html.tag('div', {class: 'long-content'}, [
+          html.tag('h1', language.$('albumCommentaryPage.title', {
+            album: link.album(album),
+          })),
+          html.tag('p', language.$('albumCommentaryPage.infoLine', {
+            words: html.tag('b', language.formatWordCount(words, {unit: true})),
+            entries: html.tag('b', language.countCommentaryEntries(entries.length, {unit: true})),
+          })),
+          ...album.commentary ? [
+            html.tag('h3', language.$('albumCommentaryPage.entry.title.albumCommentary')),
+            html.tag('blockquote', transformMultiline(album.commentary)),
+          ] : [],
+          ...album.tracks.filter(t => t.commentary).flatMap(track => [
+            html.tag('h3',
+              {id: 'track.directory'},
+              language.$('albumCommentaryPage.entry.title.trackCommentary', {
+                track: link.track(track),
+              })),
+            html.tag('blockquote',
+              {style: getLinkThemeString(track.color)},
+              transformMultiline(track.commentary)),
+          ])
+        ]),
       },
 
       nav: {
@@ -134,47 +109,20 @@ export function writeTargetless({wikiData}) {
       title: language.$('commentaryIndex.title'),
 
       main: {
-        content: fixWS`
-                    <div class="long-content">
-                        <h1>${language.$('commentaryIndex.title')}</h1>
-                        <p>${language.$('commentaryIndex.infoLine', {
-                          words: `<b>${language.formatWordCount(totalWords, {
-                            unit: true,
-                          })}</b>`,
-                          entries: `<b>${language.countCommentaryEntries(
-                            totalEntries,
-                            {
-                              unit: true,
-                            }
-                          )}</b>`,
-                        })}</p>
-                        <p>${language.$('commentaryIndex.albumList.title')}</p>
-                        <ul>
-                            ${data
-                              .map(
-                                ({album, entries, words}) => fixWS`
-                                    <li>${language.$(
-                                      'commentaryIndex.albumList.item',
-                                      {
-                                        album: link.albumCommentary(album),
-                                        words: language.formatWordCount(words, {
-                                          unit: true,
-                                        }),
-                                        entries:
-                                          language.countCommentaryEntries(
-                                            entries.length,
-                                            {
-                                              unit: true,
-                                            }
-                                          ),
-                                      }
-                                    )}</li>
-                                `
-                              )
-                              .join('\n')}
-                        </ul>
-                    </div>
-                `,
+        content: html.tag('div', {class: 'long-content'}, [
+          html.tag('h1', language.$('commentaryIndex.title')),
+          html.tag('p', language.$('commentaryIndex.infoLine', {
+            words: html.tag('b', language.formatWordCount(totalWords, {unit: true})),
+            entries: html.tag('b', language.countCommentaryEntries(totalEntries, {unit: true})),
+          })),
+          html.tag('p', language.$('commentaryIndex.albumList.title')),
+          html.tag('ul', data.map(({album, entries, words}) =>
+            html.tag('li', language.$('commentaryIndex.albumList.item', {
+              album: link.albumCommentary(album),
+              words: language.formatWordCount(words, {unit: true}),
+              entries: language.countCommentaryEntries(entries.length, {unit: true}),
+            }))))
+        ]),
       },
 
       nav: {simple: true},