mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-31 03:45:24 +01:00 
			
		
		
		
	post-cover: add support for relative path for cover image
* checks whether path mentioned in `cover` page-variable exists OR is an external url, else sets the relative path for image w.r.t the post the cover is of.
This commit is contained in:
		| @@ -33,7 +33,11 @@ | |||||||
| <article class="{{ $class }}"> | <article class="{{ $class }}"> | ||||||
|   {{- if .Params.cover }} |   {{- if .Params.cover }} | ||||||
|   <figure class="entry-cover"> |   <figure class="entry-cover"> | ||||||
|     <img src="{{ .Params.cover | absURL }}" alt="cover image for {{ .Title }}"> |     {{ if (or (fileExists (path.Join "static" .Params.cover)) (hasPrefix .Params.cover "http://") (hasPrefix .Params.cover "https://")) }} | ||||||
|  |     <img src="{{ .Params.cover | absURL }}" alt="cover image for {{ .Title | plainify }}"> | ||||||
|  |     {{else}} | ||||||
|  |     <img src="{{ .Permalink -}} {{- .Params.cover }}" alt="cover image for {{ .Title | plainify }}"> | ||||||
|  |     {{end}} | ||||||
|   </figure> |   </figure> | ||||||
|   {{- end }} |   {{- end }} | ||||||
|   <header class="entry-header"> |   <header class="entry-header"> | ||||||
|   | |||||||
| @@ -28,7 +28,11 @@ | |||||||
|   </header> |   </header> | ||||||
|   {{- if .Params.cover }} |   {{- if .Params.cover }} | ||||||
|   <figure class="entry-cover"> |   <figure class="entry-cover"> | ||||||
|  |     {{ if (or (fileExists (path.Join "static" .Params.cover)) (hasPrefix .Params.cover "http://") (hasPrefix .Params.cover "https://")) }} | ||||||
|     <img src="{{ .Params.cover | absURL }}" alt="cover image for {{ .Title | plainify }}"> |     <img src="{{ .Params.cover | absURL }}" alt="cover image for {{ .Title | plainify }}"> | ||||||
|  |     {{else}} | ||||||
|  |     <img src="{{ .Permalink -}} {{- .Params.cover }}" alt="cover image for {{ .Title | plainify }}"> | ||||||
|  |     {{end}} | ||||||
|   </figure> |   </figure> | ||||||
|   {{- end }} |   {{- end }} | ||||||
|   {{- if .Params.ShowToc }} |   {{- if .Params.ShowToc }} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aditya Telange
					Aditya Telange