11package hugolib
22
33import (
4+ "path/filepath"
45 "testing"
56
67 "github.com/spf13/afero"
@@ -26,7 +27,7 @@ tag = "tags"
2627[Languages]
2728[Languages.en]
2829staticDir2 = ["ens1", "ens2"]
29- baseURL = "https://example.com"
30+ baseURL = "https://example.com/docs "
3031weight = 10
3132title = "In English"
3233languageName = "English"
@@ -65,7 +66,7 @@ languageName = "Nynorsk"
6566 s1h := s1 .getPage (KindHome )
6667 assert .True (s1h .IsTranslated ())
6768 assert .Len (s1h .Translations (), 2 )
68- assert .Equal ("https://example.com/" , s1h .Permalink ())
69+ assert .Equal ("https://example.com/docs/ " , s1h .Permalink ())
6970
7071 // For “regular multilingual” we kept the aliases pages with url in front matter
7172 // as a literal value that we use as is.
@@ -76,12 +77,12 @@ languageName = "Nynorsk"
7677 pageWithURLInFrontMatter := s1 .getPage (KindPage , "sect/doc3.en.md" )
7778 assert .NotNil (pageWithURLInFrontMatter )
7879 assert .Equal ("/superbob" , pageWithURLInFrontMatter .URL ())
79- assert .Equal ("/superbob/" , pageWithURLInFrontMatter .RelPermalink ())
80+ assert .Equal ("/docs/ superbob/" , pageWithURLInFrontMatter .RelPermalink ())
8081 th .assertFileContent ("public/en/superbob/index.html" , "doc3|Hello|en" )
8182
8283 // check alias:
83- th .assertFileContent ("public/en/al/alias1/index.html" , `content="0; url=https://example.com/superbob/"` )
84- th .assertFileContent ("public/en/al/alias2/index.html" , `content="0; url=https://example.com/superbob/"` )
84+ th .assertFileContent ("public/en/al/alias1/index.html" , `content="0; url=https://example.com/docs/ superbob/"` )
85+ th .assertFileContent ("public/en/al/alias2/index.html" , `content="0; url=https://example.com/docs/ superbob/"` )
8586
8687 s2 := sites .Sites [1 ]
8788 assert .Equal ([]string {"s1" , "s2" , "frs1" , "frs2" }, s2 .StaticDirs ())
@@ -93,9 +94,29 @@ languageName = "Nynorsk"
9394 th .assertFileContentStraight ("public/en/index.html" , "Default Home Page" )
9495
9596 // Check paginators
96- th .assertFileContent ("public/en/page/1/index.html" , `refresh" content="0; url=https://example.com/"` )
97+ th .assertFileContent ("public/en/page/1/index.html" , `refresh" content="0; url=https://example.com/docs/ "` )
9798 th .assertFileContent ("public/nn/page/1/index.html" , `refresh" content="0; url=https://example.no/"` )
98- th .assertFileContent ("public/en/sect/page/2/index.html" , "List Page 2" , "Hello" , "https://example.com/sect/" , "\" /sect/page/3/" )
99+ th .assertFileContent ("public/en/sect/page/2/index.html" , "List Page 2" , "Hello" , "https://example.com/docs/ sect/" , "\" /docs /sect/page/3/" )
99100 th .assertFileContent ("public/fr/sect/page/2/index.html" , "List Page 2" , "Bonjour" , "https://example.fr/sect/" )
100101
102+ // Check bundles
103+
104+ bundleEn := s1 .getPage (KindPage , "bundles/b1/index.en.md" )
105+ require .NotNil (t , bundleEn )
106+ require .Equal (t , "/docs/bundles/b1/" , bundleEn .RelPermalink ())
107+ require .Equal (t , 1 , len (bundleEn .Resources ))
108+ logoEn := bundleEn .Resources .GetByPrefix ("logo" )
109+ require .NotNil (t , logoEn )
110+ require .Equal (t , "/docs/bundles/b1/logo.png" , logoEn .RelPermalink ())
111+ require .Contains (t , readFileFromFs (t , fs .Destination , filepath .FromSlash ("public/en/bundles/b1/logo.png" )), "PNG Data" )
112+
113+ bundleFr := s2 .getPage (KindPage , "bundles/b1/index.md" )
114+ require .NotNil (t , bundleFr )
115+ require .Equal (t , "/bundles/b1/" , bundleFr .RelPermalink ())
116+ require .Equal (t , 1 , len (bundleFr .Resources ))
117+ logoFr := bundleFr .Resources .GetByPrefix ("logo" )
118+ require .NotNil (t , logoFr )
119+ require .Equal (t , "/bundles/b1/logo.png" , logoFr .RelPermalink ())
120+ require .Contains (t , readFileFromFs (t , fs .Destination , filepath .FromSlash ("public/fr/bundles/b1/logo.png" )), "PNG Data" )
121+
101122}
0 commit comments