Browse Source

Add trailing slash to page paths

master
Adnan Maolood 7 months ago
parent
commit
45d08ce8fb
  1. 14
      main.go
  2. 2
      page.go

14
main.go

@ -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)

2
page.go

@ -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
}
Loading…
Cancel
Save