mirror of
https://github.com/thomasjsn/hugo-theme-hello-friend.git
synced 2024-12-25 23:39:27 +01:00
Improved code by using UseRelativeCover flag to post rather than having cover and relcover to avoid code duplication
This commit is contained in:
parent
7bf862d9d3
commit
e9aae285a6
@ -130,7 +130,7 @@ Adding a cover image to your post is simple and there are two options when you e
|
||||
|
||||
* Use `cover: "/path/to/absolute/img.jpg"` to link an absolute image
|
||||
* Resulting in `https://www.yourpage.com/path/to/absolute/img.jpg`
|
||||
* Use `relcover: "img.jpg"` to link the image relative to the blog post folder
|
||||
* Use `cover: "img.jpg"` and `useRelativeCover: true` to link the image relative to the blog post folder
|
||||
* Resulting in `https://www.yourpage.com/posts/blog-entry-xy/img.jpg`
|
||||
|
||||
## Add-ons
|
||||
|
@ -26,13 +26,12 @@
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
{{ $permalink := .Permalink }}
|
||||
{{ with .Params.RelCover }}
|
||||
<img src="{{ (printf "%s%s" $permalink . ) }}" class="post-cover" />
|
||||
{{ end }}
|
||||
|
||||
{{ with .Params.Cover }}
|
||||
<img src="{{ . | absURL }}" class="post-cover" />
|
||||
{{ if .Params.Cover }}
|
||||
{{ if .Params.UseRelativeCover }}
|
||||
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" class="post-cover" />
|
||||
{{ else }}
|
||||
<img src="{{ (urlize .Params.Cover | absURL) }}" class="post-cover" />
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="post-content">
|
||||
|
@ -20,14 +20,13 @@
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
{{ $permalink := .Permalink }}
|
||||
{{ with .Params.RelCover }}
|
||||
<img src="{{ (printf "%s%s" $permalink . ) }}" class="post-cover" />
|
||||
{{ end }}
|
||||
|
||||
{{ with .Params.Cover }}
|
||||
<img src="{{ . | absURL }}" class="post-cover" />
|
||||
{{ if .Params.Cover }}
|
||||
{{ if .Params.UseRelativeCover }}
|
||||
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" class="post-cover" />
|
||||
{{ else }}
|
||||
<img src="{{ (urlize .Params.Cover | absURL) }}" class="post-cover" />
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="post-content">
|
||||
|
Loading…
Reference in New Issue
Block a user