« get me outta code hell

linkExternalFlash.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkExternalFlash.js
blob: e2147da11592962a810bcafcca84c390852183ba (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
// Note: This function is seriously hard-coded for HSMusic, with custom
// presentation of links to Homestuck flashes hosted various places.

// This also appears to be dead code, apart from a single snapshot test??

export default {
  contentDependencies: ['linkExternal'],
  extraDependencies: ['html', 'language'],

  relations(relation, url) {
    return {
      link: relation('linkExternal', url),
    };
  },

  data(url, flash) {
    return {
      url,
      page: flash.page,
    };
  },

  generate(data, relations, {html, language}) {
    const {link} = relations;
    const {url, page} = data;

    link.setSlot('context', 'flash');

    return html.tag('span',
      {class: 'nowrap'},

      url.includes('homestuck.com')
        ? isNaN(Number(page))
          ? language.$('misc.external.flash.homestuck.secret', {link})
          : language.$('misc.external.flash.homestuck.page', {link, page})

    : url.includes('bgreco.net')
        ? language.$('misc.external.flash.bgreco', {link})

    : url.includes('youtu')
        ? language.$('misc.external.flash.youtube', {link})

        : link);
  },
};