mirror of
https://github.com/thomasjsn/hugo-theme-hello-friend.git
synced 2024-11-14 04:15:07 +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" />
|
||||
{{ 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 }}
|
||||
|
||||
{{ with .Params.Cover }}
|
||||
<img src="{{ . | absURL }}" class="post-cover" />
|
||||
{{ end }}
|
||||
|
||||
<div class="post-content">
|
||||
|
@ -21,13 +21,12 @@
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
{{ $permalink := .Permalink }}
|
||||
{{ with .Params.RelCover }}
|
||||
<img src="{{ (printf "%s%s" $permalink . ) }}" 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 }}
|
||||
|
||||
{{ with .Params.Cover }}
|
||||
<img src="{{ . | absURL }}" class="post-cover" />
|
||||
{{ end }}
|
||||
|
||||
<div class="post-content">
|
||||
|
Loading…
Reference in New Issue
Block a user