]> git.dujemihanovic.xyz Git - dujemihanovic.xyz.git/commitdiff
Properly link RSS feed in templates
authorDuje Mihanović <duje.mihanovic@skole.hr>
Wed, 30 Aug 2023 16:08:13 +0000 (18:08 +0200)
committerDuje Mihanović <duje.mihanovic@skole.hr>
Wed, 30 Aug 2023 16:28:48 +0000 (18:28 +0200)
layouts/_default/baseof.html

index 0e647e883a159f304b793ec0af02734e10d658cc..b3e08ca143fcea32bebd3551b5f5f5884a7f6507 100644 (file)
@@ -4,8 +4,10 @@
                {{ partial "meta.html" . }}
                {{ $style := resources.Get "css/style.css" | resources.Minify }}
                <link rel="stylesheet" href="{{ $style.RelPermalink }}?v=1.1.0">
-               <!-- I'm a brainlet and don't know how to properly fetch another page's feed. If you know, please tell me. -->
-               <link rel="alternate" type="application/rss+xml" href="{{ $.Site.BaseURL }}posts/index.xml" title="Blog | Duje Mihanović's Site">
+               {{ $index := $.Site.GetPage "/" }}
+               {{ range $index.AlternativeOutputFormats }}
+               {{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
+               {{ end }}
        </head>
 
        <body>
@@ -26,8 +28,9 @@
                        {{ end }}
                        {{ $image := resources.Get "img/rss.svg" }}
                        <p></p>
-                       <!-- See comment above. -->
-                       <a href="{{ $.Site.BaseURL }}posts/index.xml"><img src="{{ $image.RelPermalink }}" width="32" height="32" alt="Link to RSS feed"></a>
+                       {{ with $index.OutputFormats.Get "RSS" }}
+                       {{ printf `<a href="%s"><img src="%s" width="32" height="32" alt="Link to RSS feed"></a>` .RelPermalink $image.RelPermalink | safeHTML }}
+                       {{ end }}
                        <p>This site is <a href="https://git.dujemihanovic.xyz/?p=dujemihanovic.xyz.git;a=summary">free software</a></p>
                        </center>
                </footer>