Fix last commit
This commit is contained in:
34
main.go
34
main.go
@@ -33,7 +33,10 @@ var md = goldmark.New(
|
||||
var tmpl = template.Must(template.New("page.html").ParseFS(assets, "assets/page.html"))
|
||||
|
||||
type crumb struct{ Name, URL string }
|
||||
type entry struct{ Icon, Name, URL, Meta string }
|
||||
type entry struct {
|
||||
Icon template.HTML
|
||||
Name, URL, Meta string
|
||||
}
|
||||
|
||||
type pageData struct {
|
||||
Title string
|
||||
@@ -193,7 +196,7 @@ func listEntries(fsPath, urlPath string) []entry {
|
||||
entryURL := path.Join(urlPath, name)
|
||||
if e.IsDir() {
|
||||
folders = append(folders, entry{
|
||||
Icon: "📁",
|
||||
Icon: iconFolder,
|
||||
Name: name,
|
||||
URL: entryURL + "/",
|
||||
Meta: info.ModTime().Format("2006-01-02"),
|
||||
@@ -217,23 +220,34 @@ func listEntries(fsPath, urlPath string) []entry {
|
||||
return append(folders, files...)
|
||||
}
|
||||
|
||||
func fileIcon(name string) string {
|
||||
// Pixel-art SVG icons — outlined, crispEdges, uses currentColor.
|
||||
const (
|
||||
iconFolder template.HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="miter" shape-rendering="crispEdges"><path d="M1 6h14v8H1zm0 0V4h5l1 2"/></svg>`
|
||||
iconDoc template.HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="miter" shape-rendering="crispEdges"><path d="M3 1h7l4 4v10H3zM10 1v4h4M5 8h6M5 11h4"/></svg>`
|
||||
iconImage template.HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="miter" shape-rendering="crispEdges"><rect x="1" y="2" width="14" height="12"/><path d="M1 11l4-4 3 3 2-2 5 5"/><rect x="10" y="4" width="2" height="2" fill="currentColor" stroke="none"/></svg>`
|
||||
iconVideo template.HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="miter" shape-rendering="crispEdges"><rect x="1" y="3" width="14" height="10"/><path d="M6 6v4l5-2z" fill="currentColor" stroke="none"/></svg>`
|
||||
iconAudio template.HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" stroke="none" shape-rendering="crispEdges"><path d="M2 6h3l4-3v10l-4-3H2z"/><rect x="11" y="5" width="2" height="1"/><rect x="11" y="7" width="3" height="1"/><rect x="11" y="9" width="2" height="1"/></svg>`
|
||||
iconArchive template.HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="miter" shape-rendering="crispEdges"><rect x="1" y="1" width="14" height="4"/><path d="M1 5v10h14V5M7 3h2"/><rect x="7" y="6" width="2" height="2" fill="currentColor" stroke="none"/><rect x="7" y="9" width="2" height="1" fill="currentColor" stroke="none"/></svg>`
|
||||
iconGeneric template.HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="miter" shape-rendering="crispEdges"><path d="M3 1h7l4 4v10H3zM10 1v4h4"/></svg>`
|
||||
)
|
||||
|
||||
func fileIcon(name string) template.HTML {
|
||||
ext := strings.ToLower(path.Ext(name))
|
||||
switch ext {
|
||||
case ".md":
|
||||
return "📄"
|
||||
return iconDoc
|
||||
case ".pdf":
|
||||
return "📕"
|
||||
return iconDoc
|
||||
case ".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg":
|
||||
return "🖼"
|
||||
return iconImage
|
||||
case ".mp4", ".mkv", ".avi", ".mov":
|
||||
return "🎬"
|
||||
return iconVideo
|
||||
case ".mp3", ".flac", ".ogg", ".wav":
|
||||
return "🎵"
|
||||
return iconAudio
|
||||
case ".zip", ".tar", ".gz", ".7z":
|
||||
return "📦"
|
||||
return iconArchive
|
||||
default:
|
||||
return "📎"
|
||||
return iconGeneric
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user