Skip to content

Commit

Permalink
Add feature #16 (Add img + alt="" option to post)
Browse files Browse the repository at this point in the history
1. New front matter "image" for adding an image to a post
2. New front matter "imagetext" for alternate text for image in post

More information in README.md and features.text
  • Loading branch information
dataCobra committed Jul 26, 2020
1 parent 1985034 commit 3cbcd10
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,19 @@ Disallow page in robots.txt for search engines.

**nodate(bool)**

Hide the publish date of the page. Useful for about pages or pages required for legal reasons.
Hide the publish date of the page. Useful for about pages or pages required for
legal reasons.

**image(string)**

Add an image with /path/to/img to your post. If the path of the image in the
hugo site directoy is /static/img/picture.jpg, the correct path for the front
matter is /img/picture.jpg.

**imagetext(string)**

This is the alternate text for the image that could be added via image front
matter.

## Credits

Expand Down
3 changes: 3 additions & 0 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
.Params.disqus # Disable disqus for this specific page
.Params.hidden # Hide pages from the mainSections on the homepage
.Params.norobots # Disallow page in robots.txt for search engines
.Params.nodate # Hide the publish date of specific content
.Params.image # Add an image to the post
.Params.imagetext # Add alternate text for the image to the post
5 changes: 5 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{{ define "main" -}}
<div class="post">
{{ if isset .Params "image" }}
<div class="post-image">
<img src="{{ .Params.image }}" {{ if isset .Params "imagetext" }}alt="{{ .Params.imagetext }}"{{ end }}>
</div>
{{ end }}
<div class="author">
{{ if eq .Site.Params.listAuthor true}}
{{ if isset .Params "author" }}
Expand Down

0 comments on commit 3cbcd10

Please sign in to comment.