Shortcodes für Tabelle und Downloads eingebaut sowie eigenen Typ für feed gebaut

This commit is contained in:
mdn 2023-01-07 23:24:56 +01:00
parent 23649f935f
commit f8c72825f0
9 changed files with 137 additions and 4 deletions

22
layouts/feed/rss.xml Normal file
View file

@ -0,0 +1,22 @@
{{ $baseDir := path.Dir .Page.File }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0">
<channel>
<title>{{ .Page.Params.title }}</title>
<link>{{ .Site.BaseURL }}</link>
<description>{{ .Page.Params.description }}</description>
<language>{{ .Site.LanguageCode }}</language>
<copyright>{{ with .Site.Author.email }}{{.}}{{end}}</copyright>
<pubDate>{{ now.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ range (index .Site.Data ( .Page.Params.dataname )) }}
<item>
<title>{{ .title }}</title>
<description>{{ .comment }}</description>
<link>{{ (path.Join $baseDir .filename) | absURL }}</link>
<author>{{ with $.Site.Author.email }}{{.}}{{end}}</author>
<guid></guid>
<pubDate>{{ (time .published).Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
</item>
{{ end }}
</channel>
</rss>

View file

@ -1,7 +1,6 @@
{{ define "main" }}
<div id="home-jumbotron" class="jumbotron text-center bg-light">
<h1 class="title">{{ .Site.Title }}</h1>
<div>
{{ .Site.Params.Description }}
</div>

View file

@ -0,0 +1,14 @@
{{ $htmlTable := .content }}
<!-- Tabellenklassen hinzufügen -->
{{ $old_tbl := "<table>"}}
{{ $new_tbl := printf "<table class=\"%s\">" .table_class }}
{{ $htmlTable := replace $htmlTable $old_tbl $new_tbl }}
<!-- Tabellenkopf hinzufügen -->
{{ $old_th := "<thead>"}}
{{ $new_th := printf "<thead class=\"%s\">" .thead_class }}
{{ $htmlTable := replace $htmlTable $old_th $new_th }}
<!-- Tabellen-HTML-Code -->
{{ $htmlTable | safeHTML }}

View file

@ -0,0 +1,6 @@
<!-- Ermittle Parameter -->
{{ $htmlTable := .Inner | markdownify }}
{{ $table_class := .Get "table_class" | default "table table-hover" }}
{{ $thead_class := .Get "thead_class" | default "table-dark" }}
{{- partial "shortcodes/table" (dict "content" $htmlTable "table_class" $table_class "thead_class" $thead_class) -}}

View file

@ -0,0 +1,8 @@
{{ $dataName := .Get "data" }}
{{ $baseDir := path.Dir .Page.File }}
<ul>
{{ range (index .Site.Data (split $dataName "/")) }}
<li><a href="{{ (path.Join $baseDir .filename) | absURL }}">{{ .title }}{{ with .filesize }} ({{ int (div (div . 1024) 1024) }} MB){{ end }}</a><br/>{{ .comment }}</li>
{{ end }}
</ul>

View file

@ -0,0 +1,12 @@
{{ $dataName := .Get "data" }}
{{ $baseDir := path.Dir .Page.File }}
<ul>
{{ range (index .Site.Data (split $dataName "/")) }}
{{ $filename := (path.Join $baseDir .filename) }}
{{ $file := os.Stat $filename }}
{{ if $file }}
<li><a href="{{ $filename | absURL }}">{{ .title }} ({{ div (div $file.Size 1024) 1024 }} MB)</a><br/>{{ .comment }}</li>
{{ end }}
{{ end }}
</ul>

View file

@ -0,0 +1,17 @@
<!-- Ermittle Parameter -->
{{ $htmlTable := .Inner | markdownify }}
{{ $table_class := .Get "table_class" }}
{{ $thead_class := .Get "thead_class" }}
<!-- Tabellenklassen hinzufügen -->
{{ $old_tbl := "<table>"}}
{{ $new_tbl := printf "<table class=\"%s\">" $table_class }}
{{ $htmlTable := replace $htmlTable $old_tbl $new_tbl }}
<!-- Tabellenkopf hinzufügen -->
{{ $old_th := "<thead>"}}
{{ $new_th := printf "<thead class=\"%s\">" $thead_class }}
{{ $htmlTable := replace $htmlTable $old_th $new_th }}
<!-- Tabellen-HTML-Code -->
{{ $htmlTable | safeHTML }}