summaryrefslogtreecommitdiffstats
path: root/docs/layouts/shortcodes/code.html
blob: 4c12b0f2910e4fafb347a503393a84c5b5f621ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{{ $file := .Get "file" }}
{{ $isHTML := strings.HasSuffix $file "html" }}
<div class="code relative" id="{{ $file | urlize}}">
	{{- with $file -}}
		<div class="filename san-serif f6 dib lh-solid pl2 pv2">{{.}}</div>
	{{- end -}}

	{{ if ne (.Get "copy") "false" }}
		<button class="needs-js copy bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button">
		</button>
		{{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}}
	{{end}}
	<div class="code-copy-content nt3" {{with .Get "download"}}id="{{.}}"{{end}}>
	  	{{ if  .Get "nocode" }}{{ .Inner }}{{ else }}{{ if $isHTML }}{{- highlight .Inner  "html" "" | -}}{{ else }}<pre><code>{{- .Inner | string -}}</code></pre>{{ end }}{{ end }}
	</div>

</div>