This commit is contained in:
Christoph Herb
2024-10-10 13:20:07 +02:00
parent cf0b32dae0
commit a0c52b2fcd

View File

@@ -40,12 +40,17 @@ func (client *Client) Serve(file string) error {
if err == nil && regex.MatchString(r.URL.Path) { if err == nil && regex.MatchString(r.URL.Path) {
// Open file and convert to html // Open file and convert to html
bytes, err := readToString(dir, r.URL.Path) bytes, err := readToString(dir, r.URL.Path)
if err != nil {
log.Fatal(err)
return
}
htmlContent := client.MdToHTML(bytes) htmlContent := client.MdToHTML(bytes)
// Serve // Serve
err = serveTemplate(w, htmlStruct{Content: string(htmlContent), Darkmode: client.Dark}) err = serveTemplate(w, htmlStruct{Content: string(htmlContent), Darkmode: client.Dark})
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
return
} }
} else { } else {
chttp.ServeHTTP(w, r) chttp.ServeHTTP(w, r)