mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
36 lines
666 B
Go
36 lines
666 B
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
|
||
|
"github.com/mholt/caddy/config/setup"
|
||
|
)
|
||
|
|
||
|
// Config is the add-on configuration set on Caddyfile
|
||
|
type Config struct {
|
||
|
Styles string
|
||
|
}
|
||
|
|
||
|
// ParseHugo parses the configuration file
|
||
|
func ParseHugo(c *setup.Controller) (*Config, error) {
|
||
|
conf := &Config{}
|
||
|
|
||
|
for c.Next() {
|
||
|
for c.NextBlock() {
|
||
|
switch c.Val() {
|
||
|
case "styles":
|
||
|
if !c.NextArg() {
|
||
|
return nil, c.ArgErr()
|
||
|
}
|
||
|
conf.Styles = c.Val()
|
||
|
// Remove the beginning slash if it exists or not
|
||
|
conf.Styles = strings.TrimPrefix(conf.Styles, "/")
|
||
|
// Add a beginning slash to make a
|
||
|
conf.Styles = "/" + conf.Styles
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return conf, nil
|
||
|
}
|