diff --git a/.gitignore b/.gitignore index 7b56d29..749bc60 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ tmp indir indir-* +.zed +index.html diff --git a/main.go b/main.go index 267f123..80002ec 100755 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ import ( "strings" "time" _ "embed" - + "github.com/gomarkdown/markdown" "github.com/gomarkdown/markdown/html" "github.com/gomarkdown/markdown/parser" @@ -172,6 +172,13 @@ func main() { return } + // serve index.html if present (case-sensitive) + indexPath := filepath.Join(fpath, "index.html") + if _, err := os.Stat(indexPath); err == nil { + http.ServeFile(w, r, indexPath) + return + } + // embeded readme var readmeHTML template.HTML entries, err := os.ReadDir(fpath) @@ -190,7 +197,7 @@ func main() { } } } - + data := Directory{ Root: isRoot, Name: r.URL.Path, diff --git a/templates/dir.html b/templates/dir.html index b0b9ebf..a885117 100644 --- a/templates/dir.html +++ b/templates/dir.html @@ -56,27 +56,27 @@ .readme { margin-top: 2rem; } - - .readme h1, .readme h2, .readme h3, + + .readme h1, .readme h2, .readme h3, .readme h4, .readme h5, .readme h6 { color: #f0f0f0; margin-top: 1.2rem; } - + .readme p, .readme li { line-height: 1.7; color: #d0d0d0; } - + .readme a { color: #b7fd49; } - + .readme a:hover { color: white; text-decoration: underline; } - + .readme code { background: #1e1e1e; border: 1px solid #333; @@ -86,7 +86,7 @@ font-size: .9em; color: #b7fd79; } - + .readme pre { background: #1e1e1e; border: 3px solid #333; @@ -94,35 +94,35 @@ padding: 1em; overflow-x: auto; } - + .readme pre code { border: none; padding: 0; background: transparent; } - + .readme blockquote { border-left: 3px solid #b7fd49; margin: 0; padding-left: 1em; color: #a0a0a0; } - + .readme hr { border-color: #333; } - + .readme table { width: auto; } - + .readme table td, .readme table th { border: 1px solid #333; padding: .3em .6em; width: auto; } - + footer { padding: 1em 0; }