mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-24 14:00:42 +00:00
fix: use custom render hook templates
This commit is contained in:
parent
dafba04a6b
commit
261956c145
18
layouts/_default/_markup/render-heading.html
Normal file
18
layouts/_default/_markup/render-heading.html
Normal 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 }}
|
1
layouts/_default/_markup/render-image.html
Normal file
1
layouts/_default/_markup/render-image.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<img src="{{ .Destination | safeURL | relURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
|
2
layouts/_default/_markup/render-link.html
Normal file
2
layouts/_default/_markup/render-link.html
Normal 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>
|
@ -1,8 +1 @@
|
|||||||
{{ $showAnchor := (and (default true .Page.Params.GeekblogAnchor) (default true .Site.Params.GeekblogAnchor)) }}
|
{{ .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 }}
|
||||||
|
|
||||||
{{ $.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" }}
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<figure class="gblog-post__figure">
|
<figure class="gblog-post__figure">
|
||||||
<a href="{{ .RelPermalink }}">
|
<a class="gblog-post__link--raw" href="{{ .RelPermalink }}">
|
||||||
<img
|
<img
|
||||||
{{ with $customSize }}
|
{{ with $customSize }}
|
||||||
src="{{ index $size $customSize }}" alt="{{ $caption }}"
|
src="{{ index $size $customSize }}" alt="{{ $caption }}"
|
||||||
|
@ -329,6 +329,20 @@ img {
|
|||||||
font-size: 1.2em;
|
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 {
|
.gblog-footer {
|
||||||
|
Loading…
Reference in New Issue
Block a user