« get me outta code hell

album.js « page « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page/album.js
blob: c7327cc84a77e23025e10e707fc6b89f7950c316 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
export const description = `per-album info, artwork gallery & commentary pages`;

export function targets({wikiData}) {
  return wikiData.albumData;
}

export function pathsForTarget(album) {
  const hasCommentaryPage = !!album.commentary || album.tracks.some(t => t.commentary);

  return [
    {
      type: 'page',
      path: ['album', album.directory],

      contentFunction: {
        name: 'generateAlbumInfoPage',
        args: [album],
      },
    },

    {
      type: 'page',
      path: ['albumGallery', album.directory],

      contentFunction: {
        name: 'generateAlbumGalleryPage',
        args: [album],
      },
    },

    hasCommentaryPage && {
      type: 'page',
      path: ['albumCommentary', album.directory],

      contentFunction: {
        name: 'generateAlbumCommentaryPage',
        args: [album],
      },
    },

    /*
    {
      type: 'data',
      path: ['album', album.directory],

      contentFunction: {
        name: 'generateAlbumDataFile',
        args: [album],
      },
    },
    */
  ];
}

export function pathsTargetless({wikiData: {wikiInfo}}) {
  return [
    {
      type: 'page',
      path: ['commentaryIndex'],
      contentFunction: {name: 'generateCommentaryIndexPage'},
    },

    wikiInfo.canonicalBase === 'https://hsmusic.wiki/' &&
      {
        type: 'redirect',
        fromPath: ['page', 'list/all-commentary'],
        toPath: ['commentaryIndex'],
        title: 'Album Commentary',
      },
  ];
}

/*
export function write(album, {wikiData}) {
  const data = {
    type: 'data',
    path: ['album', album.directory],
    data: ({
      serializeContribs,
      serializeCover,
      serializeGroupsForAlbum,
      serializeLink,
    }) => ({
      name: album.name,
      directory: album.directory,
      dates: {
        released: album.date,
        trackArtAdded: album.trackArtDate,
        coverArtAdded: album.coverArtDate,
        addedToWiki: album.dateAddedToWiki,
      },
      duration: albumDuration,
      color: album.color,
      cover: serializeCover(album, getAlbumCover),
      artistContribs: serializeContribs(album.artistContribs),
      coverArtistContribs: serializeContribs(album.coverArtistContribs),
      wallpaperArtistContribs: serializeContribs(album.wallpaperArtistContribs),
      bannerArtistContribs: serializeContribs(album.bannerArtistContribs),
      groups: serializeGroupsForAlbum(album),
      trackSections: album.trackSections?.map((section) => ({
        name: section.name,
        color: section.color,
        tracks: section.tracks.map((track) => track.directory),
      })),
      tracks: album.tracks.map((track) => ({
        link: serializeLink(track),
        duration: track.duration,
      })),
    }),
  };
}
*/