fork of anirudh.fi/vite that uses chroma for hl
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add new `vite serve` command

+49 -13
+25
commands/serve.go
··· 1 + package commands 2 + 3 + import ( 4 + "fmt" 5 + "log" 6 + "net/http" 7 + ) 8 + 9 + func requestLog(h http.Handler) http.Handler { 10 + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 11 + h.ServeHTTP(w, r) 12 + log.Printf("%s\t%s", r.Method, r.URL.Path) 13 + }) 14 + } 15 + 16 + func Serve(addr string) error { 17 + fs := http.FileServer(http.Dir("./build")) 18 + mux := http.NewServeMux() 19 + mux.Handle("/", fs) 20 + fmt.Printf("vite: serving on %s\n", addr) 21 + if err := http.ListenAndServe(addr, requestLog(mux)); err != nil { 22 + return err 23 + } 24 + return nil 25 + }
+20 -10
main.go
··· 15 15 A simple and minimal static site generator. 16 16 17 17 options: 18 - init PATH create vite project at PATH 19 - build builds the current project 20 - new PATH create a new markdown post 21 - ` 18 + init PATH create vite project at PATH 19 + build builds the current project 20 + new PATH create a new markdown post 21 + serve [HOST:PORT] serves the 'build' directory 22 + ` 22 23 23 24 if len(args) <= 1 { 24 25 fmt.Println(helpStr) ··· 32 33 return 33 34 } 34 35 initPath := args[2] 35 - err := commands.Init(initPath) 36 - if err != nil { 36 + if err := commands.Init(initPath); err != nil { 37 37 fmt.Fprintf(os.Stderr, "error: init: %+v\n", err) 38 38 } 39 39 40 40 case "build": 41 - err := commands.Build() 42 - if err != nil { 41 + if err := commands.Build(); err != nil { 43 42 fmt.Fprintf(os.Stderr, "error: build: %+v\n", err) 44 43 } 45 44 ··· 49 48 return 50 49 } 51 50 newPath := args[2] 52 - err := commands.New(newPath) 53 - if err != nil { 51 + if err := commands.New(newPath); err != nil { 54 52 fmt.Fprintf(os.Stderr, "error: new: %+v\n", err) 55 53 } 54 + case "serve": 55 + var addr string 56 + if len(args) == 3 { 57 + addr = args[2] 58 + } else { 59 + addr = ":9191" 60 + } 61 + if err := commands.Serve(addr); err != nil { 62 + fmt.Fprintf(os.Stderr, "error: serve: %+v\n", err) 63 + } 64 + default: 65 + fmt.Println(helpStr) 56 66 } 57 67 58 68 }
+4 -3
readme
··· 15 15 A simple and minimal static site generator. 16 16 17 17 options: 18 - init PATH create vite project at PATH 19 - build builds the current project 20 - new PATH create a new markdown post 18 + init PATH create vite project at PATH 19 + build builds the current project 20 + new PATH create a new markdown post 21 + serve [HOST:PORT] serves the 'build' directory 21 22 22 23 23 24 CONFIG