simplify render-image using hasPrefix()

This commit is contained in:
Wouter Groeneveld 2022-07-25 15:16:26 +02:00
parent b55fe8a7f0
commit 1b99a6c434
4 changed files with 13 additions and 1788 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
"scripts": {
"prenote": "node hooks/prenote.js",
"precommit": "node hooks/precommit.js",
"search": "echo 'executing pagefind (locally)...' && /Users/wgroeneveld/.cargo/bin/pagefind --source docs --bundle-dir ../static/_pagefind",
"search": "echo 'executing Hugo+Pagefind (locally)...' && /opt/homebrew/bin/hugo && /Users/wgroeneveld/.cargo/bin/pagefind --source docs --bundle-dir ../static/_pagefind",
"postdeploy": "node hooks/postdeploy.js"
},
"repository": {

View File

@ -2,6 +2,11 @@
#search
input
width: 100%
padding: 9px 4px 9px 40px
border: 1px solid var(--accent)
border-radius: 5px
background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' class='bi bi-search' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'%3E%3C/path%3E%3C/svg%3E") no-repeat 13px center
button
background-color: white
border: 1px solid var(--accent)
@ -28,7 +33,7 @@
border-top: 1px solid lightgray
&-thumb
width: 30%
width: 40%
max-width: 120px
margin-top: 10px
aspect-ratio: 3 / 2
@ -37,10 +42,8 @@
img
display: block
position: absolute
left: 50%
transform: translateX(-50%)
font-size: 0
width: auto
height: auto
max-width: 100%
max-height: 100%
max-height: 150%

View File

@ -1,6 +1,9 @@
{{ $url := .Destination }}
<figure>
{{ $url := .Destination }}
{{ $url = replaceRE `^../(.*?)` (printf "%s%s" .Page.Permalink "../$1") $url }}
{{ if or (hasPrefix $url "/") (hasPrefix $url "https://") (hasPrefix $url "http://") }}
{{ else }}
{{ $url = (printf "%s%s" .Page.Permalink $url) }}
{{ end }}
<a href="{{ $url | absURL }}" class="lbox">
<img src="{{ $url | absURL }}" loading="lazy"{{ with .Text }} alt="{{ . }}"{{ end }}{{ with .Title}} title="{{ . }}"{{ end }}>
</a>