Add trailing slash to page paths

This commit is contained in:
Adnan Maolood 2020-11-25 14:31:58 -05:00
parent 134f38bb58
commit 45d08ce8fb
2 changed files with 3 additions and 13 deletions

14
main.go
View file

@ -58,24 +58,14 @@ type outputFormat func(*Page, *Config) (path string, content []byte)
// outputGemini outputs the page as Gemini text.
func outputGemini(p *Page, cfg *Config) (path string, content []byte) {
path = p.Path
if strings.HasSuffix(path, "/") {
path += "index.gmi"
} else {
path += "/index.gmi"
}
path = p.Path + "index.gmi"
content = []byte(p.Content)
return
}
// outputHTML outputs the page as HTML.
func outputHTML(p *Page, cfg *Config) (path string, content []byte) {
path = p.Path
if strings.HasSuffix(path, "/") {
path += "index.html"
} else {
path += "/index.html"
}
path = p.Path + "index.html"
r := strings.NewReader(p.Content)
text := gemini.ParseText(r)

View file

@ -56,7 +56,7 @@ func NewPage(path string, content []byte) *Page {
}
// Remove extension from path
page.Path = "/" + strings.TrimSuffix(path, ".gmi")
page.Path = "/" + strings.TrimSuffix(path, ".gmi") + "/"
page.Content = string(content)
return &page
}