feat: support folder index pages

This commit is contained in:
2026-04-29 09:36:52 -04:00
parent 8c454de809
commit d371c3c602
7 changed files with 223 additions and 21 deletions

View File

@@ -0,0 +1,39 @@
package docs
import (
"reflect"
"testing"
)
func TestNormalizeRequestPathCandidatesSupportsIndexFiles(t *testing.T) {
tests := []struct {
name string
path string
want []string
}{
{
name: "root",
path: "",
want: []string{"index.md", "getting-started.md"},
},
{
name: "clean folder or page path",
path: "guide",
want: []string{"guide.md", "guide/index.md"},
},
{
name: "explicit markdown path",
path: "guide/index.md",
want: []string{"guide/index.md"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := normalizeRequestPathCandidates(tt.path)
if !reflect.DeepEqual(got, tt.want) {
t.Fatalf("normalizeRequestPathCandidates(%q) = %#v, want %#v", tt.path, got, tt.want)
}
})
}
}