@@ -32,6 +32,10 @@ func TestNestedSections(t *testing.T) {
3232 th = testHelper {cfg , fs , t }
3333 )
3434
35+ cfg .Set ("permalinks" , map [string ]string {
36+ "perm a" : ":sections/:title" ,
37+ })
38+
3539 pageTemplate := `---
3640title: T%d_%d
3741---
@@ -64,6 +68,15 @@ Content
6468 writeSource (t , fs , filepath .Join ("content" , "empty3" , "b" , "c" , "d" , "_index.md" ), fmt .Sprintf (pageTemplate , 41 , - 1 ))
6569 writeSource (t , fs , filepath .Join ("content" , "empty3" , "b" , "empty3.md" ), fmt .Sprintf (pageTemplate , 3 , - 1 ))
6670
71+ // Section with permalink config
72+ writeSource (t , fs , filepath .Join ("content" , "perm a" , "link" , "_index.md" ), fmt .Sprintf (pageTemplate , 9 , - 1 ))
73+ for i := 1 ; i < 4 ; i ++ {
74+ writeSource (t , fs , filepath .Join ("content" , "perm a" , "link" , fmt .Sprintf ("page_%d.md" , i )),
75+ fmt .Sprintf (pageTemplate , 1 , i ))
76+ }
77+ writeSource (t , fs , filepath .Join ("content" , "perm a" , "link" , "regular" , fmt .Sprintf ("page_%d.md" , 5 )),
78+ fmt .Sprintf (pageTemplate , 1 , 5 ))
79+
6780 writeSource (t , fs , filepath .Join ("content" , "l1" , "l2" , "_index.md" ), fmt .Sprintf (pageTemplate , 2 , - 1 ))
6881 writeSource (t , fs , filepath .Join ("content" , "l1" , "l2_2" , "_index.md" ), fmt .Sprintf (pageTemplate , 22 , - 1 ))
6982 writeSource (t , fs , filepath .Join ("content" , "l1" , "l2" , "l3" , "_index.md" ), fmt .Sprintf (pageTemplate , 3 , - 1 ))
@@ -96,7 +109,7 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
96109 cfg .Set ("paginate" , 2 )
97110
98111 s := buildSingleSite (t , deps.DepsCfg {Fs : fs , Cfg : cfg }, BuildCfg {})
99- require .Len (t , s .RegularPages , 14 )
112+ require .Len (t , s .RegularPages , 18 )
100113
101114 tests := []struct {
102115 sections string
@@ -185,6 +198,18 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
185198 assert .Equal ("T2_-1" , p .Parent ().Title )
186199 assert .Len (p .Sections (), 0 )
187200 }},
201+ {"perm a,link" , func (p * Page ) {
202+ assert .Equal ("T9_-1" , p .Title )
203+ assert .Equal ("/perm-a/link/" , p .RelPermalink ())
204+ assert .Len (p .Pages , 4 )
205+ first := p .Pages [0 ]
206+ assert .Equal ("/perm-a/link/t1_1/" , first .RelPermalink ())
207+ th .assertFileContent ("public/perm-a/link/t1_1/index.html" , "Single|T1_1" )
208+
209+ last := p .Pages [3 ]
210+ assert .Equal ("/perm-a/link/t1_5/" , last .RelPermalink ())
211+
212+ }},
188213 }
189214
190215 for _ , test := range tests {
@@ -203,7 +228,7 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
203228
204229 assert .NotNil (home )
205230
206- assert .Len (home .Sections (), 6 )
231+ assert .Len (home .Sections (), 7 )
207232
208233 rootPage := s .getPage (KindPage , "mypage.md" )
209234 assert .NotNil (rootPage )
0 commit comments