Added the possibility to add relative cover images

This commit is contained in:
Marc Päpper 2019-03-19 17:22:40 +01:00
parent fdd6736e1d
commit 608fe3bbe9
3 changed files with 18 additions and 0 deletions

View File

@ -15,6 +15,7 @@ This theme is pretty basic and covers all of the essentials. All you have to do
- [Code highlighting](#code-highlighting) - [Code highlighting](#code-highlighting)
- [How to start](#how-to-start) - [How to start](#how-to-start)
- [How to configure](#how-to-configure) - [How to configure](#how-to-configure)
* [How to add a cover image to your posts](#how-to-add-a-cover-image-to-your-posts)
- [Add-ons](#add-ons) - [Add-ons](#add-ons)
- [How to run your site](#how-to-run-your-site) - [How to run your site](#how-to-run-your-site)
- [How to edit the theme](#how-to-edit-the-theme) - [How to edit the theme](#how-to-edit-the-theme)
@ -123,6 +124,13 @@ to `config.toml` file in your Hugo root directory and change params fields. In c
**NOTE:** Please keep in mind that currently main menu doesn't support nesting. **NOTE:** Please keep in mind that currently main menu doesn't support nesting.
## How to add a cover image to your posts
Adding a cover image to your post is simple and there are two options:
* Use `cover: "/path/to/absolute/img.jpg"` in your markdown file meta data to link an absolute image
* Use `relcover: "img.jpg" to link the image relative to the blog post folder
## Add-ons ## Add-ons
- **Comments** — for adding comments to your blog posts please take a look at `layouts/partials/comments.html` https://github.com/panr/hugo-theme-terminal/blob/master/layouts/partials/comments.html. - **Comments** — for adding comments to your blog posts please take a look at `layouts/partials/comments.html` https://github.com/panr/hugo-theme-terminal/blob/master/layouts/partials/comments.html.

View File

@ -26,6 +26,11 @@
</span> </span>
{{ end }} {{ end }}
{{ $permalink := .Permalink }}
{{ with .Params.RelCover }}
<img src="{{ (printf "%s%s" $permalink . ) }}" class="post-cover" />
{{ end }}
{{ with .Params.Cover }} {{ with .Params.Cover }}
<img src="{{ . | absURL }}" class="post-cover" /> <img src="{{ . | absURL }}" class="post-cover" />
{{ end }} {{ end }}

View File

@ -20,6 +20,11 @@
{{ end }} {{ end }}
</span> </span>
{{ end }} {{ end }}
{{ $permalink := .Permalink }}
{{ with .Params.RelCover }}
<img src="{{ (printf "%s%s" $permalink . ) }}" class="post-cover" />
{{ end }}
{{ with .Params.Cover }} {{ with .Params.Cover }}
<img src="{{ . | absURL }}" class="post-cover" /> <img src="{{ . | absURL }}" class="post-cover" />