From 14d85ec136413dcfc96ad8e4d31633f8f9cbf410 Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Mon, 4 Dec 2023 19:05:41 +0800 Subject: 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. --- hugolib/embedded_templates_test.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'hugolib') diff --git a/hugolib/embedded_templates_test.go b/hugolib/embedded_templates_test.go index b40d77dc4..a3b09e369 100644 --- a/hugolib/embedded_templates_test.go +++ b/hugolib/embedded_templates_test.go @@ -36,9 +36,9 @@ lastmod: 2021-05-22T19:25:00-01:00 --- `) - b.WithContent("mypage.md", `--- + b.WithContent("mypage/index.md", `--- title: My Page -images: ["pageimg1.jpg", "pageimg2.jpg"] +images: ["pageimg1.jpg", "pageimg2.jpg", "https://example.local/logo.png", "sample.jpg"] date: 2021-02-26T18:02:00+01:00 lastmod: 2021-05-22T19:25:00+01:00 --- @@ -58,37 +58,42 @@ title: My Site `) b.WithSunset("content/mybundle/featured-sunset.jpg") + b.WithSunset("content/mypage/sample.jpg") b.Build(BuildCfg{}) b.AssertFileContent("public/mybundle/index.html", ` - + - + - + `) b.AssertFileContent("public/mypage/index.html", ` - + + + - - + + + + `) b.AssertFileContent("public/mysite/index.html", ` - - - + + + `) } -- cgit v1.2.3