tpl: Allow using page resources on the images page parameter for opengraph, schema and twitter_cards templates

The page images selection order as follows:

1. Page's images parameter, image resources are supported.
2. Page's image resources that naming in *feature*, *cover* or *thumbnail* pattern.
3. If no page images specified, then the first one of site's images will be used as the fallback, supports site resources.
This commit is contained in:
Razon Yang
2023-12-04 19:05:41 +08:00
committed by GitHub
parent 171836cdfa
commit 14d85ec136
6 changed files with 75 additions and 51 deletions

View File

@@ -751,7 +751,7 @@ func (t *templateHandler) applyTemplateTransformers(ns *templateNamespace, ts *t
return c, err
}
//go:embed embedded/templates/*
//go:embed all:embedded/templates/*
//go:embed embedded/templates/_default/*
//go:embed embedded/templates/_server/*
var embeddedTemplatesFs embed.FS
@@ -779,7 +779,7 @@ func (t *templateHandler) loadEmbedded() error {
// For the render hooks and the server templates it does not make sense to preserve the
// double _internal double book-keeping,
// just add it if its now provided by the user.
if !strings.Contains(path, "_default/_markup") && !strings.HasPrefix(name, "_server/") {
if !strings.Contains(path, "_default/_markup") && !strings.HasPrefix(name, "_server/") && !strings.HasPrefix(name, "partials/_funcs/") {
templateName = internalPathPrefix + name
}