all repos — homestead @ 526002b13309812ce647faff2bdf66d6991ec467

Code for my website

render .md files under root as pages (x.md => /x)

Alan Pearce
commit

526002b13309812ce647faff2bdf66d6991ec467

parent

b0c19c83493787485428221330c654defcd18505

1 file changed, 10 insertions(+), 3 deletions(-)

changed files
M internal/storage/files/file.gointernal/storage/files/file.go
@@ -87,8 +87,15 @@
return strings.TrimPrefix(pathname, "/") } +func cutSuffix(s, suffix string) string { + out, _ := strings.CutSuffix(s, suffix) + + return out +} + func fileNameToPathName(filename string) string { - pathname, _ := strings.CutSuffix(filename, "index.html") - - return pathname + return cutSuffix( + cutSuffix(filename, "index.html"), + ".html", + ) }