This repository has been archived on 2025-03-15. You can view files and clone it, but cannot push or open issues or pull requests.
hui/internal/conf/dir.go
2024-07-31 19:10:32 +02:00

37 lines
716 B
Go

package conf
import (
"fmt"
"os/user"
"path/filepath"
)
func GetHomeDir() (string, error) {
usr, err := user.Current()
if err != nil {
return "", fmt.Errorf("GetHomeDir: unable to retrieve current user")
}
return usr.HomeDir, nil
}
func DataDir(homeDir string) string {
return filepath.Join(homeDir, ".hui")
}
func HugoDir(homeDir string) string {
return filepath.Join(DataDir(homeDir), "hugo")
}
func HugoBinPath(homeDir string) string {
return filepath.Join(HugoDir(homeDir), "hugo")
}
func SitesDir(homeDir string) string {
return filepath.Join(DataDir(homeDir), "sites")
}
func NewSiteDir(homeDir, newSiteName string) string {
return filepath.Join(DataDir(homeDir), "sites", newSiteName)
}