mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Create pages from _content.gotmpl
Closes #12427 Closes #12485 Closes #6310 Closes #5074
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
package resources
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"sync"
|
||||
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
"github.com/gohugoio/hugo/output"
|
||||
"github.com/gohugoio/hugo/resources/internal"
|
||||
"github.com/gohugoio/hugo/resources/jsconfig"
|
||||
"github.com/gohugoio/hugo/resources/page/pagemeta"
|
||||
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
"github.com/gohugoio/hugo/common/hexec"
|
||||
@@ -143,6 +145,16 @@ type PostBuildAssets struct {
|
||||
JSConfigBuilder *jsconfig.Builder
|
||||
}
|
||||
|
||||
func (r *Spec) NewResourceWrapperFromResourceConfig(rc *pagemeta.ResourceConfig) (resource.Resource, error) {
|
||||
content := rc.Content
|
||||
switch r := content.Value.(type) {
|
||||
case resource.Resource:
|
||||
return cloneWithMetadataFromResourceConfigIfNeeded(rc, r), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("failed to create resource for path %q, expected a resource.Resource, got %T", rc.PathInfo.Path(), content.Value)
|
||||
}
|
||||
}
|
||||
|
||||
// NewResource creates a new Resource from the given ResourceSourceDescriptor.
|
||||
func (r *Spec) NewResource(rd ResourceSourceDescriptor) (resource.Resource, error) {
|
||||
if err := rd.init(r); err != nil {
|
||||
@@ -169,9 +181,9 @@ func (r *Spec) NewResource(rd ResourceSourceDescriptor) (resource.Resource, erro
|
||||
paths: rp,
|
||||
spec: r,
|
||||
sd: rd,
|
||||
params: make(map[string]any),
|
||||
params: rd.Params,
|
||||
name: rd.NameOriginal,
|
||||
title: rd.NameOriginal,
|
||||
title: rd.Title,
|
||||
}
|
||||
|
||||
if rd.MediaType.MainType == "image" {
|
||||
|
Reference in New Issue
Block a user