fixed image display for articles without a featured image
authordanix <danix@danix.xyz>
Thu, 16 Feb 2023 18:15:12 +0000 (19:15 +0100)
committerdanix <danix@danix.xyz>
Thu, 16 Feb 2023 18:15:12 +0000 (19:15 +0100)
layouts/articles/list.html
layouts/partials/head-addition.html
layouts/partials/head.html

index 6c13939..0de0f5a 100644 (file)
        {{ range .Paginator.Pages }}
        <section>
                <a class="image" href="{{.Permalink}}">
-                       <img src="{{ .Params.featured_image | absURL}}" alt=".Title">
+               {{ if isset .Params "featured_image" }}
+                       <img src="{{ .Params.featured_image | absURL}}" alt="{{.Title}}">
+               {{ else }}
+                       {{ $default_image := resources.Get "img/default_article.jpg" }} 
+                       <img src="{{ $default_image.Permalink }}" alt="{{.Title}}">
+               {{ end }}
                </a>
                <div class="content">
                        <div class="inner">
index d2a43ec..475d3b4 100644 (file)
@@ -6,9 +6,6 @@
        <style media="screen">
                #banner {
                        background-image: url( {{ $.Params.featured_image | absURL }} );
-                       background-repeat: no-repeat;
-                       background-position: center center;
-                       background-attachment: fixed;
                }
        </style>
        {{ end }}
index 4045dc6..46f5ee3 100644 (file)
@@ -11,7 +11,7 @@
 
        <link rel="stylesheet" href="{{ $style.RelPermalink }}">
        <link rel="stylesheet" href="{{ "css/syntax.css" |relURL }}">
-       <noscript><link rel="stylesheet" href="{{ $noscript.RelPermalink }}" /></noscript>
+       <noscript><link rel="stylesheet" href="{{ $noscript.RelPermalink }}" ></noscript>
        {{ partial "funcs/favicon.html" . }}
        <link rel="canonical" href="{{ .Permalink }}">