package main

import (
	"log"
	"net/http"

	"chaosmith-site/blog"
)

func main() {
	mux := http.NewServeMux()
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "index.html")
	})
	mux.HandleFunc("/ABSTRACTS.png", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "ABSTRACTS.png")
	})
	mux.Handle("/src/", http.StripPrefix("/src/", http.FileServer(http.Dir("src"))))
	mux.Handle("/content/images/", http.StripPrefix("/content/images/", http.FileServer(http.Dir("content/images"))))

	if err := blog.RegisterRoutes(mux, "content/posts"); err != nil {
		log.Fatalf("blog: %v", err)
	}

	log.Println("listening on :8000")
	http.ListenAndServe(":8000", mux)
}
