aboutsummaryrefslogtreecommitdiff
path: root/layouts/shortcodes/music.html
blob: 22b2268e61663903f778f1328b14c93c34422268 (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
  {{/*
      ## Music 163
  
      ### Params:
  
      - `id`
  
        required param
        you can extract from music url
        url format "http://music.163.com/#/song?id=3950552"
  
      - Fiddle `auto`
  
        optional param
        default value 0
        you can overwrite it with 1
  
      ### Examples:
  
      - Simple
  
        {{% music "3950552" %}}
        {{% music "3950552" "1" %}}
  
      - Named Params
  
        {{% music id="3950552" %}}
        {{% music id="3950552" auto="1" %}}
  
  */}}
  
  {{- /* DEFAULTS */ -}}
  {{ $auto := "0" }}
  
  {{- if .IsNamedParams -}}
  
    <iframe style="max-width: 100%"
      class="music163"
      frameborder="no"
      border="0"
      marginwidth="0"
      marginheight="0"
      width="330"
      height="86"
      src="//music.163.com/outchain/player?type=2&id={{ .Get "id" }}&auto={{ or (.Get "auto") $auto }}&height=66">
    </iframe>
  
  {{- else -}}
  
    <iframe style="max-width: 100%"
      class="music163"
      frameborder="no"
      border="0"
      marginwidth="0"
      marginheight="0"
      width="330"
      height="86"
      src="//music.163.com/outchain/player?type=2&id={{ .Get 0 }}&auto={{ if isset .Params 1 }}{{ .Get 1 }}{{ else }}{{ $auto }}{{ end }}&height=66">
    </iframe>
  
  {{- end -}}