Use path/filepath instead of path

This commit is contained in:
Adnan Maolood 2022-02-09 12:36:59 -05:00
parent fe04b580e8
commit 36ba349639

21
main.go
View file

@ -8,7 +8,6 @@ import (
"io/fs"
"log"
"os"
"path"
"path/filepath"
"strings"
)
@ -139,23 +138,23 @@ func copyAll(srcDir, dstDir string) error {
var builtin embed.FS
func newSite(name string) {
name = path.Clean(name)
name = filepath.Clean(name)
os.Mkdir(name, 0755)
os.Mkdir(path.Join(name, "content"), 0755)
os.Mkdir(path.Join(name, "templates"), 0755)
os.Mkdir(path.Join(name, "templates/_default"), 0755)
os.Mkdir(path.Join(name, "static"), 0755)
os.Mkdir(path.Join(name, "public"), 0755)
os.Mkdir(filepath.Join(name, "content"), 0755)
os.Mkdir(filepath.Join(name, "templates"), 0755)
os.Mkdir(filepath.Join(name, "templates", "_default"), 0755)
os.Mkdir(filepath.Join(name, "static"), 0755)
os.Mkdir(filepath.Join(name, "public"), 0755)
config, _ := builtin.ReadFile("config.toml")
os.WriteFile(path.Join(name, "config.toml"), config, 0644)
os.WriteFile(filepath.Join(name, "config.toml"), config, 0644)
index := []byte("---\ntitle: Hello, world!\n---\n")
os.WriteFile(path.Join(name, "content/_index.gmi"), index, 0644)
os.WriteFile(filepath.Join(name, "content", "_index.gmi"), index, 0644)
templates := []string{"atom.xml", "index.gmi", "page.gmi"}
for _, template := range templates {
b, _ := builtin.ReadFile(path.Join("templates/_default", template))
os.WriteFile(path.Join(name, "templates/_default", template), b, 0644)
b, _ := builtin.ReadFile(filepath.Join("templates", "_default", template))
os.WriteFile(filepath.Join(name, "templates", "_default", template), b, 0644)
}
}