aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/resource_factories
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-01-04 18:24:36 +0100
committerBjørn Erik Pedersen <[email protected]>2023-05-16 18:01:29 +0200
commit241b21b0fd34d91fccb2ce69874110dceae6f926 (patch)
treed4e0118eac7e9c42f065815447a70805f8d6ad3e /resources/resource_factories
parent6aededf6b42011c3039f5f66487a89a8dd65e0e7 (diff)
downloadhugo-241b21b0fd34d91fccb2ce69874110dceae6f926.tar.gz
hugo-241b21b0fd34d91fccb2ce69874110dceae6f926.zip
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
Diffstat (limited to 'resources/resource_factories')
-rw-r--r--resources/resource_factories/bundler/bundler.go6
-rw-r--r--resources/resource_factories/create/create.go1
-rw-r--r--resources/resource_factories/create/remote.go2
3 files changed, 5 insertions, 4 deletions
diff --git a/resources/resource_factories/bundler/bundler.go b/resources/resource_factories/bundler/bundler.go
index 7de228227..67f1f90fa 100644
--- a/resources/resource_factories/bundler/bundler.go
+++ b/resources/resource_factories/bundler/bundler.go
@@ -88,8 +88,8 @@ func (c *Client) Concat(targetPath string, r resource.Resources) (resource.Resou
// The given set of resources must be of the same Media Type.
// We may improve on that in the future, but then we need to know more.
for i, r := range r {
- if i > 0 && r.MediaType().Type() != resolvedm.Type() {
- return nil, fmt.Errorf("resources in Concat must be of the same Media Type, got %q and %q", r.MediaType().Type(), resolvedm.Type())
+ if i > 0 && r.MediaType().Type != resolvedm.Type {
+ return nil, fmt.Errorf("resources in Concat must be of the same Media Type, got %q and %q", r.MediaType().Type, resolvedm.Type)
}
resolvedm = r.MediaType()
}
@@ -115,7 +115,7 @@ func (c *Client) Concat(targetPath string, r resource.Resources) (resource.Resou
// Arbitrary JavaScript files require a barrier between them to be safely concatenated together.
// Without this, the last line of one file can affect the first line of the next file and change how both files are interpreted.
- if resolvedm.MainType == media.JavascriptType.MainType && resolvedm.SubType == media.JavascriptType.SubType {
+ if resolvedm.MainType == media.Builtin.JavascriptType.MainType && resolvedm.SubType == media.Builtin.JavascriptType.SubType {
readers := make([]hugio.ReadSeekCloser, 2*len(rcsources)-1)
j := 0
for i := 0; i < len(rcsources); i++ {
diff --git a/resources/resource_factories/create/create.go b/resources/resource_factories/create/create.go
index b8ac5bb34..2e4721299 100644
--- a/resources/resource_factories/create/create.go
+++ b/resources/resource_factories/create/create.go
@@ -136,6 +136,7 @@ func (c *Client) match(name, pattern string, matchFunc func(r resource.Resource)
}
// FromString creates a new Resource from a string with the given relative target path.
+// TODO(bep) see #10912; we currently emit a warning for this config scenario.
func (c *Client) FromString(targetPath, content string) (resource.Resource, error) {
return c.rs.ResourceCache.GetOrCreate(path.Join(resources.CACHE_OTHER, targetPath), func() (resource.Resource, error) {
return c.rs.New(
diff --git a/resources/resource_factories/create/remote.go b/resources/resource_factories/create/remote.go
index 7310569f9..3aae57e8d 100644
--- a/resources/resource_factories/create/remote.go
+++ b/resources/resource_factories/create/remote.go
@@ -197,7 +197,7 @@ func (c *Client) FromRemote(uri string, optionsm map[string]any) (resource.Resou
}
// Now resolve the media type primarily using the content.
- mediaType = media.FromContent(c.rs.MediaTypes, extensionHints, body)
+ mediaType = media.FromContent(c.rs.MediaTypes(), extensionHints, body)
}