mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
Create a struct with all of Hugo's config options
Primary motivation is documentation, but it will also hopefully simplify the code. Also, * Lower case the default output format names; this is in line with the custom ones (map keys) and how it's treated all the places. This avoids doing `stringds.EqualFold` everywhere. Closes #10896 Closes #10620
This commit is contained in:
@@ -16,18 +16,16 @@ package htesting
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gohugoio/hugo/cache/filecache"
|
||||
"github.com/gohugoio/hugo/config"
|
||||
"github.com/gohugoio/hugo/config/testconfig"
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
"github.com/gohugoio/hugo/media"
|
||||
"github.com/gohugoio/hugo/output"
|
||||
"github.com/gohugoio/hugo/resources"
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
func NewTestResourceSpec() (*resources.Spec, error) {
|
||||
cfg := config.NewWithTestDefaults()
|
||||
cfg := config.New()
|
||||
|
||||
imagingCfg := map[string]any{
|
||||
"resampleFilter": "linear",
|
||||
@@ -36,20 +34,16 @@ func NewTestResourceSpec() (*resources.Spec, error) {
|
||||
}
|
||||
|
||||
cfg.Set("imaging", imagingCfg)
|
||||
afs := afero.NewMemMapFs()
|
||||
|
||||
fs := hugofs.NewFrom(hugofs.NewBaseFileDecorator(afero.NewMemMapFs()), cfg)
|
||||
|
||||
s, err := helpers.NewPathSpec(fs, cfg, nil)
|
||||
conf := testconfig.GetTestConfig(afs, cfg)
|
||||
fs := hugofs.NewFrom(hugofs.NewBaseFileDecorator(afs), conf.BaseConfig())
|
||||
s, err := helpers.NewPathSpec(fs, conf, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filecaches, err := filecache.NewCaches(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
spec, err := resources.NewSpec(s, filecaches, nil, nil, nil, nil, output.DefaultFormats, media.DefaultTypes)
|
||||
spec, err := resources.NewSpec(s, nil, nil, nil, nil, nil)
|
||||
return spec, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user