sync theme

This commit is contained in:
Christoph Cullmann 2024-07-15 22:27:55 +02:00
parent 69075c6fb1
commit 3be5285488
No known key found for this signature in database
856 changed files with 236 additions and 1388275 deletions

View file

@ -5,7 +5,8 @@
{{ end }}
{{- range $pages -}}
{{- $section := .Site.GetPage "section" .Section -}}
{{- $index = $index | append (dict
{{- if .Date -}}
{{- $index = $index | append (dict
"date" (.Date | time.Format (.Site.Language.Params.dateFormat | default ":date_long"))
"title" (.Title | emojify | safeJS)
"section" ($section.Title | emojify | safeJS)
@ -14,6 +15,17 @@
"permalink" .RelPermalink
"externalUrl" .Params.externalUrl
"type" .Type
) -}}
) -}}
{{- else -}}
{{- $index = $index | append (dict
"title" (.Title | emojify | safeJS)
"section" ($section.Title | emojify | safeJS)
"summary" (.Summary | safeJS)
"content" (.Plain | safeJS)
"permalink" .RelPermalink
"externalUrl" .Params.externalUrl
"type" .Type
) -}}
{{- end -}}
{{- end -}}
{{- $index | jsonify -}}

View file

@ -1,16 +1,21 @@
{{ if isset site.Params.umamiAnalytics "domain" }}
<script data-id="umami-script" async src="https://{{ site.Params.umamiAnalytics.domain }}/script.js" data-website-id="{{ site.Params.umamiAnalytics.websiteid }}">
<script data-id="umami-script" async
src="https://{{ site.Params.umamiAnalytics.domain }}/script.js"
data-website-id="{{ site.Params.umamiAnalytics.websiteid }}"
{{ with site.Params.umamiAnalytics.dataDomains }}data-domains="{{ . }}"{{ end }}>
</script>
{{ else }}
<script data-id="umami-script" async src="https://analytics.umami.is/script.js" data-website-id="{{ site.Params.umamiAnalytics.websiteid }}">
<script data-id="umami-script" async src="https://analytics.umami.is/script.js"
data-website-id="{{ site.Params.umamiAnalytics.websiteid }}">
</script>
{{ end }}
<script type="text/javascript">
document.querySelector('script[data-id="umami-script"]').addEventListener('load', function () {
const type = document.head.querySelector('meta[property = "og:type"]').getAttribute('content');
let title = document.head.querySelector('meta[property = "og:title"]').getAttribute('content');
let url = document.head.querySelector('meta[property = "og:url"]').getAttribute('content');
umami.track(type + ':' + title, {'url': url});
document.querySelector('script[data-id="umami-script"]')
.addEventListener('load', function () {
const type = document.head.querySelector('meta[property = "og:type"]').getAttribute('content');
let title = document.head.querySelector('meta[property = "og:title"]').getAttribute('content');
let url = document.head.querySelector('meta[property = "og:url"]').getAttribute('content');
umami.track(type + ':' + title, {'url': url});
});
</script>

View file

@ -1,8 +1,27 @@
{{ $url := .Get "url" }}
{{ $type := .Get "type" }}
{{ $startLine := .Get "startLine" | default 1 | int }}
{{ $startLine = sub $startLine 1 }}
{{ $endLine := .Get "endLine" | default -1 | int }}
{{ $selectedLines := slice }}
{{ with resources.GetRemote (urls.Parse $url) }}
{{ $codeBlock := printf "```%s\n%s\n```" $type .Content }}
{{ $codeBlock | markdownify }}
{{ $lines := split .Content "\n" }}
{{ $totalLine := $lines | len }}
{{ if ne $endLine -1 }}
{{ $endLine = math.Min $endLine $totalLine }}
{{ else }}
{{ $endLine = $totalLine }}
{{ end }}
{{ if gt $startLine $endLine }}
{{ errorf "Code Importer Shortcode - startLine is greater than endLine" . }}
{{ end }}
{{ $selectedLines := first $endLine $lines }}
{{ $selectedLines = after $startLine $selectedLines }}
{{ $codeBlock := printf "```%s\n%s\n```" $type (delimit $selectedLines "\n") }}
{{ $codeBlock | markdownify }}
{{ else }}
{{ errorf "Code Importer Shortcode - Unable to get remote resource" . }}
{{ errorf "Code Importer Shortcode - Unable to get remote resource" . }}
{{ end }}