// Command build pre-renders the whole site into a directory. // // It reads content/ and writes dist/: every page as HTML, one file per stage // fragment, the fragment manifest, the SQLite FTS5 index, the assets and the // static files. No network call is made, and the output is what the server // serves — Mode A never renders a page per request. // // Configuration is from the environment, so the same binary is used by // `make build`, by CI and by the container image: // // RESUME_ROOT repository root (default ".") // RESUME_CONTENT content directory (default $RESUME_ROOT/content) // RESUME_DIST output directory (default $RESUME_ROOT/dist) package main import ( "flag" "fmt" "os" "gitea.lab.audasmedia.com.au/sam/ai-resume/internal/site" ) func main() { flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), "usage: build [--root DIR] [--content DIR] [--dist DIR]\n") fmt.Fprintf(flag.CommandLine.Output(), "environment: RESUME_ROOT, RESUME_CONTENT, RESUME_DIST\n") } root := flag.String("root", env("RESUME_ROOT", "."), "repository root") contentDir := flag.String("content", env("RESUME_CONTENT", ""), "content directory") distDir := flag.String("dist", env("RESUME_DIST", ""), "output directory") flag.Parse() cfg := site.Config{Root: *root, ContentDir: *contentDir, OutDir: *distDir} s, err := site.New(cfg) if err != nil { fmt.Fprintf(os.Stderr, "build: %v\n", err) os.Exit(1) } if err := s.Build(); err != nil { fmt.Fprintf(os.Stderr, "build: %v\n", err) os.Exit(1) } info, err := site.LoadBuildInfo(s.Config.OutDir) if err != nil { fmt.Fprintf(os.Stderr, "build: %v\n", err) os.Exit(1) } fmt.Printf("built %d pages, %d stage fragments, %d indexed documents into %s\n", info.Pages, info.Fragments, info.Indexed, s.Config.OutDir) } func env(key, fallback string) string { if v := os.Getenv(key); v != "" { return v } return fallback }