2024-07-09 21:10:03 +00:00
|
|
|
{{ define "main" }}
|
|
|
|
<header>
|
|
|
|
<h2>{{ .Title }}</h2>
|
|
|
|
<p>{{ .Description }}</p>
|
2024-09-18 13:25:24 +00:00
|
|
|
|
|
|
|
{{- with .GetTerms "author" }}
|
|
|
|
{{- range . -}}
|
|
|
|
<div class="author">
|
|
|
|
di <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
|
|
|
</div>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
2024-07-09 21:10:03 +00:00
|
|
|
{{ if .Site.Params.show_post_dates | default true }}
|
|
|
|
{{- with .Date }}<time>{{ . | time.Format ":date_medium" }}</time>{{ end }}
|
|
|
|
{{ end }}
|
2024-09-20 10:14:52 +00:00
|
|
|
{{- with .Params.location_link -}}
|
|
|
|
<div class="location">{{ T "location" }}: {{ . | markdownify }}</div>
|
|
|
|
{{ end }}
|
2024-09-13 21:42:06 +00:00
|
|
|
{{- with .Params.license -}}
|
|
|
|
<div class="license">{{ T "license" }}: {{ . | markdownify }}</div>
|
|
|
|
{{ end }}
|
2024-07-09 21:10:03 +00:00
|
|
|
{{ partial "tags.html" . }}
|
|
|
|
</header>
|
|
|
|
|
2024-11-12 13:08:17 +00:00
|
|
|
{{- $image_src := "" }}
|
|
|
|
{{- $image_alt := "" }}
|
|
|
|
{{- $image_caption := "" }}
|
2024-07-09 21:10:03 +00:00
|
|
|
|
2024-11-12 13:08:17 +00:00
|
|
|
{{/* priorità maggiore: image_post */}}
|
|
|
|
{{- if .Params.image_post }}
|
|
|
|
{{- $image_src = .Params.image_post.src }}
|
|
|
|
{{- with .Params.image_post.alt }}
|
|
|
|
{{- $image_alt = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with .Params.image_post.caption }}
|
|
|
|
{{- $image_caption = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{/* in alternativa uso il metodo vecchio */}}
|
|
|
|
{{- if and (not $image_src) .Params.image }}
|
|
|
|
{{- $image_src = .Params.image }}
|
|
|
|
{{- with .Params.image_alt }}
|
|
|
|
{{- $image_alt = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with .Params.image_caption }}
|
|
|
|
{{- $image_caption = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- if $image_src }}
|
|
|
|
{{- $image := .Page.Resources.GetMatch $image_src }}
|
2024-07-13 18:19:41 +00:00
|
|
|
{{- $maxHeight := 600 -}}
|
2024-07-20 11:40:47 +00:00
|
|
|
{{- $ratio := 2.33 -}}
|
2024-07-09 21:10:03 +00:00
|
|
|
|
2024-07-27 22:59:43 +00:00
|
|
|
<span class="image featured"><figure>
|
2024-11-12 13:08:17 +00:00
|
|
|
{{- if gt $image.Height $maxHeight -}}
|
|
|
|
{{- $image = $image.Resize (printf "x%d webp q50" $maxHeight) -}}
|
2024-07-27 22:59:43 +00:00
|
|
|
{{- end -}}
|
2024-11-12 13:08:17 +00:00
|
|
|
<img src="{{ $image.RelPermalink }}" alt="{{ $image_alt }}" {{- if ge (mul $image.Height $ratio) $image.Width -}}style="width: auto;" {{- end -}}/>
|
|
|
|
{{- with $image_caption -}}
|
|
|
|
<figcaption style="max-width: {{- $image.Width -}}px;">{{- . | markdownify -}}</figcaption>
|
2024-07-27 22:59:43 +00:00
|
|
|
{{- end -}}
|
|
|
|
</figure></span>
|
2024-07-09 21:10:03 +00:00
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{- .Content }}
|
2024-07-30 21:57:17 +00:00
|
|
|
|
|
|
|
{{ if (findRE "<pre" .Content 1) }}
|
|
|
|
<script>
|
|
|
|
function addCopyButtons(clipboard) {
|
|
|
|
document.querySelectorAll('pre > code').forEach(function (codeBlock) {
|
|
|
|
var button = document.createElement('button');
|
|
|
|
button.className = 'copy-code-button';
|
|
|
|
button.type = 'button';
|
|
|
|
button.innerText = 'Copy';
|
|
|
|
|
|
|
|
button.addEventListener('click', function () {
|
|
|
|
clipboard.writeText(codeBlock.innerText).then(function () {
|
|
|
|
/* Chrome doesn't seem to blur automatically,
|
|
|
|
leaving the button in a focused state. */
|
|
|
|
button.blur();
|
|
|
|
|
|
|
|
button.innerText = 'Copied!';
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
button.innerText = 'Copy';
|
|
|
|
}, 2000);
|
|
|
|
}, function (error) {
|
|
|
|
button.innerText = 'Error';
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var pre = codeBlock.parentNode;
|
|
|
|
if (pre.parentNode.classList.contains('highlight')) {
|
|
|
|
var highlight = pre.parentNode;
|
|
|
|
highlight.parentNode.insertBefore(button, highlight);
|
|
|
|
} else {
|
|
|
|
pre.parentNode.insertBefore(button, pre);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (navigator && navigator.clipboard) {
|
|
|
|
addCopyButtons(navigator.clipboard);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{{ end }}
|
|
|
|
|
2024-07-09 21:10:03 +00:00
|
|
|
{{ end }}
|