« get me outta code hell

pre-writes: art tags, artists & aliases - 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-02-16 23:04:08 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-02-16 23:04:08 -0400
commitf8557485ac06a7b2527c50dcf638497212678a16 (patch)
treed869354ea475d517f1ef0ac699107f94355187b9 /src/page
parenta447a03576ec5e346b0381f0845ecdc302d7e11f (diff)
pre-writes: art tags, artists & aliases
Diffstat (limited to 'src/page')
-rw-r--r--src/page/artist-alias.js4
-rw-r--r--src/page/artist.js43
-rw-r--r--src/page/tag.js4
3 files changed, 34 insertions, 17 deletions
diff --git a/src/page/artist-alias.js b/src/page/artist-alias.js
index d03510a8..c7b0feb6 100644
--- a/src/page/artist-alias.js
+++ b/src/page/artist-alias.js
@@ -8,12 +8,12 @@ export function targets({wikiData}) {
 export function write(aliasArtist, {wikiData}) {
     // This function doesn't actually use wikiData, 8ut, um, consistency?
 
-    const { alias: targetArtist } = aliasArtist;
+    const { aliasedArtist } = aliasArtist;
 
     const redirect = {
         type: 'redirect',
         fromPath: ['artist', aliasArtist.directory],
-        toPath: ['artist', targetArtist.directory],
+        toPath: ['artist', aliasedArtist.directory],
         title: () => aliasArtist.name
     };
 
diff --git a/src/page/artist.js b/src/page/artist.js
index 5cdb97f1..b89107fc 100644
--- a/src/page/artist.js
+++ b/src/page/artist.js
@@ -38,9 +38,22 @@ export function write(artist, {wikiData}) {
         note = ''
     } = artist;
 
-    const artThingsAll = sortByDate(unique([...artist.albums.asCoverArtist, ...artist.albums.asWallpaperArtist, ...artist.albums.asBannerArtist, ...artist.tracks.asCoverArtist]));
-    const artThingsGallery = sortByDate([...artist.albums.asCoverArtist, ...artist.tracks.asCoverArtist]);
-    const commentaryThings = sortByDate([...artist.albums.asCommentator, ...artist.tracks.asCommentator]);
+    const artThingsAll = sortByDate(unique([
+        ...artist.albumsAsCoverArtist ?? [],
+        ...artist.albumsAsWallpaperArtist ?? [],
+        ...artist.albumsAsBannerArtist ?? [],
+        ...artist.tracksAsCoverArtist ?? []
+    ]));
+
+    const artThingsGallery = sortByDate([
+        ...artist.albumsAsCoverArtist ?? [],
+        ...artist.tracksAsCoverArtist ?? []
+    ]);
+
+    const commentaryThings = sortByDate([
+        ...artist.albumsAsCommentator ?? [],
+        ...artist.tracksAsCommentator ?? []
+    ]);
 
     const hasGallery = artThingsGallery.length > 0;
 
@@ -68,7 +81,11 @@ export function write(artist, {wikiData}) {
         track: thing.album ? thing : null
     })), ['album']);
 
-    const allTracks = sortByDate(unique([...artist.tracks.asArtist, ...artist.tracks.asContributor]));
+    const allTracks = sortByDate(unique([
+        ...artist.tracksAsArtist ?? [],
+        ...artist.tracksAsContributor ?? []
+    ]));
+
     const unreleasedTracks = allTracks.filter(track => track.album.directory === UNRELEASED_TRACKS_DIRECTORY);
     const releasedTracks = allTracks.filter(track => track.album.directory !== UNRELEASED_TRACKS_DIRECTORY);
 
@@ -115,7 +132,7 @@ export function write(artist, {wikiData}) {
 
     let flashes, flashListChunks;
     if (wikiInfo.enableFlashesAndGames) {
-        flashes = sortByDate(artist.flashes.asContributor.slice());
+        flashes = sortByDate(artist.flashesAsContributor?.slice() ?? []);
         flashListChunks = (
             chunkByProperties(flashes.map(flash => ({
                 act: flash.act,
@@ -228,21 +245,21 @@ export function write(artist, {wikiData}) {
 
             return {
                 albums: {
-                    asCoverArtist: artist.albums.asCoverArtist.map(serializeArtistsAndContrib('coverArtists')),
-                    asWallpaperArtist: artist.albums.asWallpaperArtist.map(serializeArtistsAndContrib('wallpaperArtists')),
-                    asBannerArtist: artist.albums.asBannerArtist.map(serializeArtistsAndContrib('bannerArtists'))
+                    asCoverArtist: artist.albumsAsCoverArtist?.map(serializeArtistsAndContrib('coverArtists')),
+                    asWallpaperArtist: artist.albumsAsWallpaperArtist?.map(serializeArtistsAndContrib('wallpaperArtists')),
+                    asBannerArtist: artist.albumsAsBannerArtist?.map(serializeArtistsAndContrib('bannerArtists'))
                 },
                 flashes: wikiInfo.enableFlashesAndGames ? {
-                    asContributor: artist.flashes.asContributor
-                        .map(flash => getArtistsAndContrib(flash, 'contributors'))
+                    asContributor: (artist.flashesAsContributor
+                        ?.map(flash => getArtistsAndContrib(flash, 'contributors'))
                         .map(({ contrib, thing: flash }) => ({
                             link: serializeLink(flash),
                             contribution: contrib.what
-                        }))
+                        })))
                 } : null,
                 tracks: {
-                    asArtist: artist.tracks.asArtist.map(serializeArtistsAndContrib('artists')),
-                    asContributor: artist.tracks.asContributor.map(serializeArtistsAndContrib('contributors')),
+                    asArtist: artist.tracksAsArtist.map(serializeArtistsAndContrib('artists')),
+                    asContributor: artist.tracksAsContributor.map(serializeArtistsAndContrib('contributors')),
                     chunked: {
                         released: serializeTrackListChunks(releasedTrackListChunks),
                         unreleased: serializeTrackListChunks(unreleasedTrackListChunks)
diff --git a/src/page/tag.js b/src/page/tag.js
index 60b8d217..6090cb08 100644
--- a/src/page/tag.js
+++ b/src/page/tag.js
@@ -11,7 +11,7 @@ export function condition({wikiData}) {
 }
 
 export function targets({wikiData}) {
-    return wikiData.tagData.filter(tag => !tag.isCW);
+    return wikiData.artTagData.filter(tag => !tag.isCW);
 }
 
 export function write(tag, {wikiData}) {
@@ -82,7 +82,7 @@ function generateTagNav(tag, {
     wikiData
 }) {
     const previousNextLinks = generatePreviousNextLinks(tag, {
-        data: wikiData.tagData.filter(tag => !tag.isCW),
+        data: wikiData.artTagData.filter(tag => !tag.isCW),
         linkKey: 'tag'
     });