mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 09:23:09 +00:00
Add trailing slash to page paths
This commit is contained in:
parent
134f38bb58
commit
45d08ce8fb
14
main.go
14
main.go
|
@ -58,24 +58,14 @@ type outputFormat func(*Page, *Config) (path string, content []byte)
|
||||||
|
|
||||||
// outputGemini outputs the page as Gemini text.
|
// outputGemini outputs the page as Gemini text.
|
||||||
func outputGemini(p *Page, cfg *Config) (path string, content []byte) {
|
func outputGemini(p *Page, cfg *Config) (path string, content []byte) {
|
||||||
path = p.Path
|
path = p.Path + "index.gmi"
|
||||||
if strings.HasSuffix(path, "/") {
|
|
||||||
path += "index.gmi"
|
|
||||||
} else {
|
|
||||||
path += "/index.gmi"
|
|
||||||
}
|
|
||||||
content = []byte(p.Content)
|
content = []byte(p.Content)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// outputHTML outputs the page as HTML.
|
// outputHTML outputs the page as HTML.
|
||||||
func outputHTML(p *Page, cfg *Config) (path string, content []byte) {
|
func outputHTML(p *Page, cfg *Config) (path string, content []byte) {
|
||||||
path = p.Path
|
path = p.Path + "index.html"
|
||||||
if strings.HasSuffix(path, "/") {
|
|
||||||
path += "index.html"
|
|
||||||
} else {
|
|
||||||
path += "/index.html"
|
|
||||||
}
|
|
||||||
|
|
||||||
r := strings.NewReader(p.Content)
|
r := strings.NewReader(p.Content)
|
||||||
text := gemini.ParseText(r)
|
text := gemini.ParseText(r)
|
||||||
|
|
2
page.go
2
page.go
|
@ -56,7 +56,7 @@ func NewPage(path string, content []byte) *Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove extension from path
|
// Remove extension from path
|
||||||
page.Path = "/" + strings.TrimSuffix(path, ".gmi")
|
page.Path = "/" + strings.TrimSuffix(path, ".gmi") + "/"
|
||||||
page.Content = string(content)
|
page.Content = string(content)
|
||||||
return &page
|
return &page
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue