summaryrefslogtreecommitdiff
path: root/layouts/_shortcodes/music.html
blob: 98e6531c11dc9c6d305da0d3ea1a85c25bf52a8e (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
{{ $title := .Get "title" }}
{{ $cover := .Get "cover" }}
{{ $artist := .Get "artist" }}
{{ $isAlbum := .Get "album" }}

{{ $platforms := slice "bandcamp" "apple" "spotify" "netease" "tidal" "neodb" "lucida" "archive" }}
{{ $page := . }}

<div class="flex flex-col md:flex-row md:justify-between md:items-center gap-2">
    <!-- Cover, title, artist -->
    <div class="flex gap-5 items-center">
        <div class="relative flex-shrink-0">
            <img class="w-15 h-15 rd-lg shadow-lg m-0!"
                alt="{{ $title }} music cover"
                src="{{ $cover }}" loading="lazy" />
            {{ if $isAlbum }}
            <div class="w-13 h-13 rd-md bg-neutral-400 dark:bg-neutral-600 absolute top-1 left-3 -z-1"></div>
            {{ end }}
        </div>
        <div>
            <h4 class="m-0 text-size-base flex items-center gap-2 leading-tight">
                <span>{{ $title }}</span>
                {{ if $isAlbum }}
                <span class="font-mono bg-neutral-700 text-white
                      px-1 rd text-xs leading-relaxed hidden sm:inline-block"
                    >{{ T "music.album" }}</span>
                {{ end }}
            </h4>
            <p class="m-0! text-size-sm text-secondary">{{ $artist }}</p>
        </div>
    </div>
    <!-- Links -->
    <div class="flex gap-2 items-center">
        {{ range $platforms }}
            {{ $code := . }}
            {{ $langcode := (printf "music.%s" $code) }}
            {{ $name := T $langcode }}
            {{ with $page.Get . }}
            <a href="{{ . }}"
                class="block rounded-full px-3 md:p-4 bg-neutral-200/50 dark:bg-neutral-600/50 hover:bg-neutral-200 dark:hover:bg-neutral-600 transition-colors no-underline! text-size-xs inline-flex gap-1 items-center"
                target="_blank"
                title="{{ T "music.openIn" $name }}"
                data-tooltip
            >
                <img src="{{ printf "/icons/music/%s.png" $code }}"
                    alt="{{ $name }}"
                    loading="lazy" class="block w-3 h-3 md:w-5 md:h-5 m-0!" />
                <span class="md:hidden">{{ $name }}</span>
            </a>
            {{ end }}
        {{ end }}
    </div>
</div>