mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Allow creating home pages from content adapters
* Allow "" (empty string) or "/" to represent the home page path. * Be a little more lenient about path validation.
This commit is contained in:
@@ -149,13 +149,12 @@ var DefaultPageConfig = PageConfig{
|
||||
Build: DefaultBuildConfig,
|
||||
}
|
||||
|
||||
func (p *PageConfig) Validate(pagesFromData bool) error {
|
||||
func (p *PageConfig) Init(pagesFromData bool) error {
|
||||
if pagesFromData {
|
||||
if p.Path == "" {
|
||||
return errors.New("path must be set")
|
||||
}
|
||||
if strings.HasPrefix(p.Path, "/") {
|
||||
return fmt.Errorf("path %q must not start with a /", p.Path)
|
||||
p.Path = strings.TrimPrefix(p.Path, "/")
|
||||
|
||||
if p.Path == "" && p.Kind != kinds.KindHome {
|
||||
return fmt.Errorf("empty path is reserved for the home page")
|
||||
}
|
||||
if p.Lang != "" {
|
||||
return errors.New("lang must not be set")
|
||||
@@ -295,9 +294,6 @@ type ResourceConfig struct {
|
||||
}
|
||||
|
||||
func (rc *ResourceConfig) Validate() error {
|
||||
if rc.Path == "" {
|
||||
return errors.New("path must be set")
|
||||
}
|
||||
if rc.Content.Markup != "" {
|
||||
return errors.New("markup must not be set, use mediaType")
|
||||
}
|
||||
|
Reference in New Issue
Block a user