hugolib, tplimpl: Use OutputFormats to create atom links
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 25 Mar 2017 09:14:12 +0000 (10:14 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 27 Mar 2017 13:43:56 +0000 (15:43 +0200)
hugolib/hugo_sites_build_test.go
tpl/tplimpl/template_embedded.go

index 5f3ef7a70b1e03b785c46a83fd2d40c4f1991e15..e0d3ce7b8cc8bb5752d9e67c3fbc9729ca5b135c 100644 (file)
@@ -112,13 +112,13 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
        th.assertFileContent("public/en/sitemap.xml", "<loc>http://example.com/blog/en/</loc>")
 
        // Check rss
-       // TODO(bep) output the Atom link must be cretated from the OutputFormats.RSS.Permalink
-       //      th.assertFileContent("public/fr/index.xml", `<atom:link href="http://example.com/blog/fr/index.xml"`)
-       //      th.assertFileContent("public/en/index.xml", `<atom:link href="http://example.com/blog/en/index.xml"`)
-       //      th.assertFileContent("public/fr/sect/index.xml", `<atom:link href="http://example.com/blog/fr/sect/index.xml"`)
-       //      th.assertFileContent("public/en/sect/index.xml", `<atom:link href="http://example.com/blog/en/sect/index.xml"`)
-       //      th.assertFileContent("public/fr/plaques/frtag1/index.xml", `<atom:link href="http://example.com/blog/fr/plaques/frtag1/index.xml"`)
-       //      th.assertFileContent("public/en/tags/tag1/index.xml", `<atom:link href="http://example.com/blog/en/tags/tag1/index.xml"`)
+       th.assertFileContent("public/fr/index.xml", `<atom:link href="http://example.com/blog/fr/index.xml"`,
+               `rel="self" type="application/rss+xml"`)
+       th.assertFileContent("public/en/index.xml", `<atom:link href="http://example.com/blog/en/index.xml"`)
+       th.assertFileContent("public/fr/sect/index.xml", `<atom:link href="http://example.com/blog/fr/sect/index.xml"`)
+       th.assertFileContent("public/en/sect/index.xml", `<atom:link href="http://example.com/blog/en/sect/index.xml"`)
+       th.assertFileContent("public/fr/plaques/frtag1/index.xml", `<atom:link href="http://example.com/blog/fr/plaques/frtag1/index.xml"`)
+       th.assertFileContent("public/en/tags/tag1/index.xml", `<atom:link href="http://example.com/blog/en/tags/tag1/index.xml"`)
 
        // Check paginators
        th.assertFileContent("public/fr/page/1/index.html", `refresh" content="0; url=http://example.com/blog/fr/"`)
index 2aabe9c9cb9f909fafcd059cf8e7317212566ba9..56819b764cbb6a8dded37783c4e1d63450934a6f 100644 (file)
@@ -76,7 +76,9 @@ func (t *GoHTMLTemplate) EmbedTemplates() {
     <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
     <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
     <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
-    <atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" />
+    {{ with .OutputFormats.Get "RSS" }}
+       {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
+    {{ end }}
     {{ range .Data.Pages }}
     <item>
       <title>{{ .Title }}</title>