2024-02-10 11:37:38 -03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-02-15 12:38:17 -03:00
|
|
|
"path/filepath"
|
2024-02-14 13:16:41 -03:00
|
|
|
|
|
|
|
"github.com/facundoolano/blorg/site"
|
2024-02-10 11:37:38 -03:00
|
|
|
)
|
|
|
|
|
2024-02-12 15:16:56 -03:00
|
|
|
const SRC_DIR = "src"
|
|
|
|
const TARGET_DIR = "target"
|
2024-02-12 16:27:06 -03:00
|
|
|
const LAYOUTS_DIR = "layouts"
|
2024-02-12 15:16:56 -03:00
|
|
|
|
2024-02-10 11:37:38 -03:00
|
|
|
func Init() error {
|
|
|
|
// get working directory
|
|
|
|
// default to .
|
|
|
|
// if not exist, create directory
|
|
|
|
// copy over default files
|
|
|
|
fmt.Println("not implemented yet")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func New() error {
|
|
|
|
// prompt for title
|
|
|
|
// slugify
|
|
|
|
// fail if file already exist
|
|
|
|
// create a new .org file with the slug
|
|
|
|
// add front matter and org options
|
|
|
|
fmt.Println("not implemented yet")
|
|
|
|
return nil
|
|
|
|
}
|
2024-02-14 23:54:46 -03:00
|
|
|
|
|
|
|
// Read the files in src/ render them and copy the result to target/
|
2024-02-15 12:38:17 -03:00
|
|
|
func Build(root string) error {
|
|
|
|
src := filepath.Join(root, SRC_DIR)
|
|
|
|
target := filepath.Join(root, TARGET_DIR)
|
|
|
|
layouts := filepath.Join(root, LAYOUTS_DIR)
|
|
|
|
|
|
|
|
site, err := site.Load(src, layouts)
|
2024-02-14 23:54:46 -03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-02-15 12:38:17 -03:00
|
|
|
return site.Build(src, target, true, false)
|
2024-02-14 23:54:46 -03:00
|
|
|
}
|