mirror of
https://github.com/thomasjsn/hugo-theme-hello-friend.git
synced 2024-11-25 09: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
|
* Use `cover: "/path/to/absolute/img.jpg"` to link an absolute image
|
||||||
* Resulting in `https://www.yourpage.com/path/to/absolute/img.jpg`
|
* 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`
|
* Resulting in `https://www.yourpage.com/posts/blog-entry-xy/img.jpg`
|
||||||
|
|
||||||
## Add-ons
|
## Add-ons
|
||||||
|
@ -26,13 +26,12 @@
|
|||||||
</span>
|
</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $permalink := .Permalink }}
|
{{ if .Params.Cover }}
|
||||||
{{ with .Params.RelCover }}
|
{{ if .Params.UseRelativeCover }}
|
||||||
<img src="{{ (printf "%s%s" $permalink . ) }}" class="post-cover" />
|
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" class="post-cover" />
|
||||||
{{ end }}
|
{{ else }}
|
||||||
|
<img src="{{ (urlize .Params.Cover | absURL) }}" class="post-cover" />
|
||||||
{{ with .Params.Cover }}
|
{{ end }}
|
||||||
<img src="{{ . | absURL }}" class="post-cover" />
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
|
@ -21,13 +21,12 @@
|
|||||||
</span>
|
</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $permalink := .Permalink }}
|
{{ if .Params.Cover }}
|
||||||
{{ with .Params.RelCover }}
|
{{ if .Params.UseRelativeCover }}
|
||||||
<img src="{{ (printf "%s%s" $permalink . ) }}" class="post-cover" />
|
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" class="post-cover" />
|
||||||
{{ end }}
|
{{ else }}
|
||||||
|
<img src="{{ (urlize .Params.Cover | absURL) }}" class="post-cover" />
|
||||||
{{ with .Params.Cover }}
|
{{ end }}
|
||||||
<img src="{{ . | absURL }}" class="post-cover" />
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
|
Loading…
Reference in New Issue
Block a user