« get me outta code hell

page: artist-alias: don't overshadow a normal artist page - 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>2024-08-01 17:51:29 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-08-01 17:58:08 -0300
commit7be872b48d2886e7331ca38b33005d40ffb187c0 (patch)
tree3bd1123933223322c30dc07298e66f7c91da4826 /src/page
parent4c3caa297be6f73f07821d2dab4071cf239712b4 (diff)
page: artist-alias: don't overshadow a normal artist page
Also moves filtering logic into targets().
Diffstat (limited to 'src/page')
-rw-r--r--src/page/artist-alias.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/page/artist-alias.js b/src/page/artist-alias.js
index c1177798..6af5ef8a 100644
--- a/src/page/artist-alias.js
+++ b/src/page/artist-alias.js
@@ -1,18 +1,32 @@
 export const description = `redirects for aliased artist names`;
 
 export function targets({wikiData}) {
-  return wikiData.artistData.filter(artist => artist.isAlias);
+  const normalArtistDirectories =
+    wikiData.artistData
+      .filter(artist => !artist.isAlias)
+      .map(artist => artist.directory);
+
+  return (
+    wikiData.artistData
+      .filter(artist => artist.isAlias)
+
+      // Don't generate a redirect page if this aliased name resolves to the
+      // same directory as the original artist! See issue #280.
+      .filter(aliasArtist =>
+        aliasArtist.directory !==
+        aliasArtist.aliasedArtist.directory)
+
+      // And don't generate a redirect page if this aliased name resolves to the
+      // same directory as any *other, non-alias* artist. In that case we really
+      // just need the page (at this directory) to lead to the actual artist with
+      // this directory - not be a redirect. See issue #543.
+      .filter(aliasArtist =>
+        !normalArtistDirectories.includes(aliasArtist.directory)));
 }
 
 export function pathsForTarget(aliasArtist) {
   const {aliasedArtist} = aliasArtist;
 
-  // Don't generate a redirect page if this aliased name resolves to the same
-  // directory as the original artist! See issue #280.
-  if (aliasArtist.directory === aliasedArtist.directory) {
-    return [];
-  }
-
   return [
     {
       type: 'redirect',