Compare commits

...

4 commits

3 changed files with 24 additions and 15 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
tmp tmp
indir indir
indir-* indir-*
.zed
index.html

11
main.go
View file

@ -14,7 +14,7 @@ import (
"strings" "strings"
"time" "time"
_ "embed" _ "embed"
"github.com/gomarkdown/markdown" "github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html" "github.com/gomarkdown/markdown/html"
"github.com/gomarkdown/markdown/parser" "github.com/gomarkdown/markdown/parser"
@ -172,6 +172,13 @@ func main() {
return 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 // embeded readme
var readmeHTML template.HTML var readmeHTML template.HTML
entries, err := os.ReadDir(fpath) entries, err := os.ReadDir(fpath)
@ -190,7 +197,7 @@ func main() {
} }
} }
} }
data := Directory{ data := Directory{
Root: isRoot, Root: isRoot,
Name: r.URL.Path, Name: r.URL.Path,

View file

@ -56,27 +56,27 @@
.readme { .readme {
margin-top: 2rem; margin-top: 2rem;
} }
.readme h1, .readme h2, .readme h3, .readme h1, .readme h2, .readme h3,
.readme h4, .readme h5, .readme h6 { .readme h4, .readme h5, .readme h6 {
color: #f0f0f0; color: #f0f0f0;
margin-top: 1.2rem; margin-top: 1.2rem;
} }
.readme p, .readme li { .readme p, .readme li {
line-height: 1.7; line-height: 1.7;
color: #d0d0d0; color: #d0d0d0;
} }
.readme a { .readme a {
color: #b7fd49; color: #b7fd49;
} }
.readme a:hover { .readme a:hover {
color: white; color: white;
text-decoration: underline; text-decoration: underline;
} }
.readme code { .readme code {
background: #1e1e1e; background: #1e1e1e;
border: 1px solid #333; border: 1px solid #333;
@ -86,7 +86,7 @@
font-size: .9em; font-size: .9em;
color: #b7fd79; color: #b7fd79;
} }
.readme pre { .readme pre {
background: #1e1e1e; background: #1e1e1e;
border: 3px solid #333; border: 3px solid #333;
@ -94,35 +94,35 @@
padding: 1em; padding: 1em;
overflow-x: auto; overflow-x: auto;
} }
.readme pre code { .readme pre code {
border: none; border: none;
padding: 0; padding: 0;
background: transparent; background: transparent;
} }
.readme blockquote { .readme blockquote {
border-left: 3px solid #b7fd49; border-left: 3px solid #b7fd49;
margin: 0; margin: 0;
padding-left: 1em; padding-left: 1em;
color: #a0a0a0; color: #a0a0a0;
} }
.readme hr { .readme hr {
border-color: #333; border-color: #333;
} }
.readme table { .readme table {
width: auto; width: auto;
} }
.readme table td, .readme table td,
.readme table th { .readme table th {
border: 1px solid #333; border: 1px solid #333;
padding: .3em .6em; padding: .3em .6em;
width: auto; width: auto;
} }
footer { footer {
padding: 1em 0; padding: 1em 0;
} }