fix: use custom render hook templates

This commit is contained in:
Robert Kaussow 2021-02-21 13:24:55 +01:00
parent dafba04a6b
commit 261956c145
Signed by: xoxys
GPG Key ID: 65362AE74AF98B61
6 changed files with 37 additions and 9 deletions

View File

@ -0,0 +1,18 @@
{{ $showAnchor := (and (default true .Page.Params.GeekblogAnchor) (default true .Page.Site.Params.GeekblogAnchor)) }}
{{ if $showAnchor }}
<div class="gblog-post__anchorwrap">
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
{{ .Text | safeHTML }}
<a data-clipboard-text="{{ .Page.Permalink }}#{{ .Anchor | safeURL }}" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor {{ .Text | safeHTML }}" href="#{{ .Anchor | safeURL }}">
<svg class="icon link"><use xlink:href="#link"></use></svg>
</a>
</h{{ .Level }}>
</div>
{{ else }}
<div class="gblog-post__anchorwrap">
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
{{ .Text | safeHTML }}
</h{{ .Level }}>
</div>
{{ end }}

View File

@ -0,0 +1 @@
<img src="{{ .Destination | safeURL | relURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />

View File

@ -0,0 +1,2 @@
{{ $raw := or (hasPrefix .Text "<img") (hasPrefix .Text "<figure") }}
<a class="gblog-post__link{{ if $raw }}--raw{{ end }}" href="{{ .Destination | safeURL | relURL }}"{{ with .Title }} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>

View File

@ -1,8 +1 @@
{{ $showAnchor := (and (default true .Page.Params.GeekblogAnchor) (default true .Site.Params.GeekblogAnchor)) }}
{{ $.Scratch.Set "content" (.Content | replaceRE `<nav id="TableOfContents">\s*<ul>\s*<li>\s*<ul>` `<nav id="TableOfContents"><ul>` | replaceRE `</ul>\s*</li>\s*</ul>\s*</nav>` `</ul></nav>` | safeHTML) }}
{{ if $showAnchor }}
{{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" (printf `<div class="gblog-post__anchorwrap">%s%s<a data-clipboard-text="%s" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor %s" href="#%s"><svg class="icon link"><use xlink:href="#link"></use></svg></a>%s</div>` `${1}` `${3}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${3}` `${2}` `${4}`) | safeHTML) }}
{{ end }}
{{ $.Scratch.Get "content" }}
{{ .Content | replaceRE `<nav id="TableOfContents">\s*<ul>\s*<li>\s*<ul>` `<nav id="TableOfContents"><ul>` | replaceRE `</ul>\s*</li>\s*</ul>\s*</nav>` `</ul></nav>` | safeHTML }}

View File

@ -14,7 +14,7 @@
<div class="flex justify-center">
<figure class="gblog-post__figure">
<a href="{{ .RelPermalink }}">
<a class="gblog-post__link--raw" href="{{ .RelPermalink }}">
<img
{{ with $customSize }}
src="{{ index $size $customSize }}" alt="{{ $caption }}"

View File

@ -329,6 +329,20 @@ img {
font-size: 1.2em;
}
}
&__link--raw {
text-decoration: none;
color: $body-font-color;
&:hover {
background: none;
color: $body-font-color;
}
&:visited {
color: $body-font-color;
}
}
}
.gblog-footer {