Revert "simplify page with https://github.com/adityatelange/hugo-PaperMod.git"
This reverts commit c2189ef133
.
This commit is contained in:
parent
c2189ef133
commit
fc43dba964
540 changed files with 29285 additions and 6036 deletions
31
themes/blowfish/layouts/shortcodes/gallery.html
Normal file
31
themes/blowfish/layouts/shortcodes/gallery.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
{{ $id := delimit (slice "gallery" (partial "functions/uid.html" .)) "-" }}
|
||||
|
||||
<div id="{{ $id }}" class="gallery">
|
||||
{{ $page := .Page }}
|
||||
|
||||
{{/* find all img tags */}}
|
||||
{{ $imgTagRegex := `<img\s+[^>]*>` }}
|
||||
{{ $imgTags := findRE $imgTagRegex .Inner }}
|
||||
{{ $newContent := .Inner }}
|
||||
|
||||
{{ range $imgTags }}
|
||||
{{ $imgTag := . }}
|
||||
{{/* extract src attribute */}}
|
||||
{{ $srcRegex := `src=['"]([^'"]+)['"]` }}
|
||||
{{ $srcMatches := findRESubmatch $srcRegex $imgTag }}
|
||||
|
||||
{{ if $srcMatches }}
|
||||
{{ $srcFull := index (index $srcMatches 0) 0 }}
|
||||
{{ $src := index (index $srcMatches 0) 1 }}
|
||||
|
||||
{{ $resource := $page.Resources.GetMatch $src }}
|
||||
{{ if $resource }}
|
||||
{{ $newSrc := printf `src="%s"` $resource.RelPermalink }}
|
||||
{{ $newImg := replace $imgTag $srcFull $newSrc }}
|
||||
{{ $newContent = replace $newContent $imgTag $newImg }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $newContent | safeHTML }}
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue