Add lang attribute to internal alias template

Closes #9586
This commit is contained in:
Joe Mooring 2022-03-01 20:27:52 -08:00 committed by Bjørn Erik Pedersen
parent cdb8b0842b
commit f98e570b17
4 changed files with 16 additions and 7 deletions

View file

@ -71,8 +71,8 @@ func TestAlias(t *testing.T) {
// the real page // the real page
b.AssertFileContent("public/blog/page"+test.fileSuffix, "For some moments the old man") b.AssertFileContent("public/blog/page"+test.fileSuffix, "For some moments the old man")
// the alias redirectors // the alias redirectors
b.AssertFileContent("public/foo/bar"+test.fileSuffix, "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page"+test.urlSuffix+"\" />") b.AssertFileContent("public/foo/bar"+test.fileSuffix, "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page"+test.urlSuffix+"\">")
b.AssertFileContent("public/blog/rel"+test.fileSuffix, "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page"+test.urlSuffix+"\" />") b.AssertFileContent("public/blog/rel"+test.fileSuffix, "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page"+test.urlSuffix+"\">")
} }
} }

View file

@ -83,14 +83,14 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
c.Assert(frRelPerm, qt.Equals, "/blog/fr/sect/doc1/") c.Assert(frRelPerm, qt.Equals, "/blog/fr/sect/doc1/")
// should have a redirect on top level. // should have a redirect on top level.
b.AssertFileContent("public/index.html", `<meta http-equiv="refresh" content="0; url=http://example.com/blog/fr" />`) b.AssertFileContent("public/index.html", `<meta http-equiv="refresh" content="0; url=http://example.com/blog/fr">`)
} else { } else {
// Main language in root // Main language in root
c.Assert(frPerm, qt.Equals, "http://example.com/blog/sect/doc1/") c.Assert(frPerm, qt.Equals, "http://example.com/blog/sect/doc1/")
c.Assert(frRelPerm, qt.Equals, "/blog/sect/doc1/") c.Assert(frRelPerm, qt.Equals, "/blog/sect/doc1/")
// should have redirect back to root // should have redirect back to root
b.AssertFileContent("public/fr/index.html", `<meta http-equiv="refresh" content="0; url=http://example.com/blog" />`) b.AssertFileContent("public/fr/index.html", `<meta http-equiv="refresh" content="0; url=http://example.com/blog">`)
} }
b.AssertFileContent(pathMod("public/fr/index.html"), "Home", "Bonjour") b.AssertFileContent(pathMod("public/fr/index.html"), "Home", "Bonjour")
b.AssertFileContent("public/en/index.html", "Home", "Hello") b.AssertFileContent("public/en/index.html", "Home", "Hello")

View file

@ -1653,11 +1653,11 @@ tags:
th.assertFileContent(pathFunc("public/post/test0.dot/index.html"), "some content") th.assertFileContent(pathFunc("public/post/test0.dot/index.html"), "some content")
if uglyURLs { if uglyURLs {
th.assertFileContent("public/post/page/1.html", `canonical" href="/post.html"/`) th.assertFileContent("public/post/page/1.html", `canonical" href="/post.html"`)
th.assertFileContent("public/post.html", `<body>P1|URL: /post.html|Next: /post/page/2.html</body>`) th.assertFileContent("public/post.html", `<body>P1|URL: /post.html|Next: /post/page/2.html</body>`)
th.assertFileContent("public/post/page/2.html", `<body>P2|URL: /post/page/2.html|Next: /post/page/3.html</body>`) th.assertFileContent("public/post/page/2.html", `<body>P2|URL: /post/page/2.html|Next: /post/page/3.html</body>`)
} else { } else {
th.assertFileContent("public/post/page/1/index.html", `canonical" href="/post/"/`) th.assertFileContent("public/post/page/1/index.html", `canonical" href="/post/"`)
th.assertFileContent("public/post/index.html", `<body>P1|URL: /post/|Next: /post/page/2/</body>`) th.assertFileContent("public/post/index.html", `<body>P1|URL: /post/|Next: /post/page/2/</body>`)
th.assertFileContent("public/post/page/2/index.html", `<body>P2|URL: /post/page/2/|Next: /post/page/3/</body>`) th.assertFileContent("public/post/page/2/index.html", `<body>P2|URL: /post/page/2/|Next: /post/page/3/</body>`)
th.assertFileContent("public/tags/.net/index.html", `<body>P1|URL: /tags/.net/|Next: /tags/.net/page/2/</body>`) th.assertFileContent("public/tags/.net/index.html", `<body>P1|URL: /tags/.net/|Next: /tags/.net/page/2/</body>`)

View file

@ -1 +1,10 @@
<!DOCTYPE html><html><head><title>{{ .Permalink }}</title><link rel="canonical" href="{{ .Permalink }}"/><meta name="robots" content="noindex"><meta charset="utf-8" /><meta http-equiv="refresh" content="0; url={{ .Permalink }}" /></head></html> <!DOCTYPE html>
<html{{ with site.LanguageCode | default site.Language.Lang }} lang="{{ . }}"{{ end }}>
<head>
<title>{{ .Permalink }}</title>
<link rel="canonical" href="{{ .Permalink }}">
<meta name="robots" content="noindex">
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url={{ .Permalink }}">
</head>
</html>