this repo has no description
1package config 2 3import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 8 "gopkg.in/yaml.v3" 9) 10 11type Config struct { 12 Repo struct { 13 ScanPath string `yaml:"scanPath"` 14 Readme []string `yaml:"readme"` 15 MainBranch []string `yaml:"mainBranch"` 16 Ignore []string `yaml:"ignore,omitempty"` 17 Unlisted []string `yaml:"unlisted,omitempty"` 18 } `yaml:"repo"` 19 Dirs struct { 20 Templates string `yaml:"templates"` 21 Static string `yaml:"static"` 22 } `yaml:"dirs"` 23 Meta struct { 24 Title string `yaml:"title"` 25 Description string `yaml:"description"` 26 SyntaxHighlight string `yaml:"syntaxHighlight"` 27 } `yaml:"meta"` 28 Server struct { 29 Name string `yaml:"name,omitempty"` 30 Host string `yaml:"host"` 31 Port int `yaml:"port"` 32 DBPath string `yaml:"dbpath"` 33 } `yaml:"server"` 34} 35 36func Read(f string) (*Config, error) { 37 b, err := os.ReadFile(f) 38 if err != nil { 39 return nil, fmt.Errorf("reading config: %w", err) 40 } 41 42 c := Config{} 43 if err := yaml.Unmarshal(b, &c); err != nil { 44 return nil, fmt.Errorf("parsing config: %w", err) 45 } 46 47 if c.Repo.ScanPath, err = filepath.Abs(c.Repo.ScanPath); err != nil { 48 return nil, err 49 } 50 if c.Dirs.Templates, err = filepath.Abs(c.Dirs.Templates); err != nil { 51 return nil, err 52 } 53 if c.Dirs.Static, err = filepath.Abs(c.Dirs.Static); err != nil { 54 return nil, err 55 } 56 57 return &c, nil 58}