« 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: 65158ff81509ef040271ceab23fff3e2a167b819 (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
// Note: This function is seriously hard-coded for HSMusic, with custom
// presentation of links to Homestuck flashes hosted various places.

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;

    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);
  },
};