« get me outta code hell

artist-alias.js « page « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page/artist-alias.js
blob: 6af5ef8a1cba37e7bb282477354f4aadb6af35fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
export const description = `redirects for aliased artist names`;

export function targets({wikiData}) {
  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;

  return [
    {
      type: 'redirect',
      fromPath: ['artist', aliasArtist.directory],
      toPath: ['artist', aliasedArtist.directory],
      title: aliasedArtist.name,
    },
  ];
}