mirror of
https://github.com/thebaer/cdr.git
synced 2024-11-15 01:31:01 +00:00
Add static site generation
Run `cdr burn` to create an index.html file in the current directory.
This commit is contained in:
parent
79db8a0cd1
commit
2246bed69b
@ -17,6 +17,11 @@ var (
|
||||
Usage: "serve the mixtape site",
|
||||
Action: serveAction,
|
||||
}
|
||||
cmdGenerate = cli.Command{
|
||||
Name: "burn",
|
||||
Usage: "generate the static mixtape site",
|
||||
Action: generateAction,
|
||||
}
|
||||
)
|
||||
|
||||
func newMixtape(wd string) (*cdr.Mixtape, error) {
|
||||
@ -38,6 +43,31 @@ func newMixtape(wd string) (*cdr.Mixtape, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func generateAction(c *cli.Context) error {
|
||||
f, err := os.Create("index.html")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m, err := newMixtape(wd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = cdr.Render(m, f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func serveAction(c *cli.Context) error {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
|
@ -16,6 +16,7 @@ func main() {
|
||||
}
|
||||
|
||||
app.Commands = []*cli.Command{
|
||||
&cmdGenerate,
|
||||
&cmdServe,
|
||||
&cmdClean,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user