@@ -305,3 +305,109 @@ title: p2
305305 "<?xml version=\" 1.0\" encoding=\" utf-8\" standalone=\" yes\" ?>\n <urlset xmlns=\" http://www.sitemaps.org/schemas/sitemap/0.9\" \n xmlns:xhtml=\" http://www.w3.org/1999/xhtml\" >\n <url>\n <loc>/p2/</loc>\n </url>\n </urlset>\n " ,
306306 )
307307}
308+
309+ // Issue 12418
310+ func TestOpengraph (t * testing.T ) {
311+ t .Parallel ()
312+
313+ files := `
314+ -- hugo.toml --
315+ capitalizeListTitles = false
316+ disableKinds = ['rss','sitemap']
317+ languageCode = 'en-US'
318+ [markup.goldmark.renderer]
319+ unsafe = true
320+ [params]
321+ description = "m <em>n</em> and **o** can't."
322+ [params.social]
323+ facebook_admin = 'foo'
324+ [taxonomies]
325+ series = 'series'
326+ tag = 'tags'
327+ -- layouts/_default/list.html --
328+ {{ template "_internal/opengraph.html" . }}
329+ -- layouts/_default/single.html --
330+ {{ template "_internal/opengraph.html" . }}
331+ -- content/s1/p1.md --
332+ ---
333+ title: p1
334+ date: 2024-04-24T08:00:00-07:00
335+ lastmod: 2024-04-24T11:00:00-07:00
336+ images: [a.jpg,b.jpg]
337+ audio: [c.mp3,d.mp3]
338+ videos: [e.mp4,f.mp4]
339+ series: [series-1]
340+ tags: [t1,t2]
341+ ---
342+ a <em>b</em> and **c** can't.
343+ -- content/s1/p2.md --
344+ ---
345+ title: p2
346+ series: [series-1]
347+ ---
348+ d <em>e</em> and **f** can't.
349+ <!--more-->
350+ -- content/s1/p3.md --
351+ ---
352+ title: p3
353+ series: [series-1]
354+ summary: g <em>h</em> and **i** can't.
355+ ---
356+ -- content/s1/p4.md --
357+ ---
358+ title: p4
359+ series: [series-1]
360+ description: j <em>k</em> and **l** can't.
361+ ---
362+ -- content/s1/p5.md --
363+ ---
364+ title: p5
365+ series: [series-1]
366+ ---
367+ `
368+
369+ b := hugolib .Test (t , files )
370+
371+ b .AssertFileContent ("public/s1/p1/index.html" , `
372+ <meta property="og:url" content="/s1/p1/">
373+ <meta property="og:title" content="p1">
374+ <meta property="og:description" content="a b and c can’t.">
375+ <meta property="og:locale" content="en-US">
376+ <meta property="og:type" content="article">
377+ <meta property="article:section" content="s1">
378+ <meta property="article:published_time" content="2024-04-24T08:00:00-07:00">
379+ <meta property="article:modified_time" content="2024-04-24T11:00:00-07:00">
380+ <meta property="article:tag" content="t1">
381+ <meta property="article:tag" content="t2">
382+ <meta property="og:image" content="/a.jpg">
383+ <meta property="og:image" content="/b.jpg">
384+ <meta property="og:audio" content="/c.mp3">
385+ <meta property="og:audio" content="/d.mp3">
386+ <meta property="og:video" content="/e.mp4">
387+ <meta property="og:video" content="/f.mp4">
388+ <meta property="og:see_also" content="/s1/p2/">
389+ <meta property="og:see_also" content="/s1/p3/">
390+ <meta property="og:see_also" content="/s1/p4/">
391+ <meta property="og:see_also" content="/s1/p5/">
392+ <meta property="fb:admins" content="foo">
393+ ` ,
394+ )
395+
396+ b .AssertFileContent ("public/s1/p2/index.html" ,
397+ `<meta property="og:description" content="d e and f can’t.">` ,
398+ )
399+
400+ b .AssertFileContent ("public/s1/p3/index.html" ,
401+ `<meta property="og:description" content="g h and i can’t.">` ,
402+ )
403+
404+ // The markdown is intentionally not rendered to HTML.
405+ b .AssertFileContent ("public/s1/p4/index.html" ,
406+ `<meta property="og:description" content="j k and **l** can't.">` ,
407+ )
408+
409+ // The markdown is intentionally not rendered to HTML.
410+ b .AssertFileContent ("public/s1/p5/index.html" ,
411+ `<meta property="og:description" content="m n and **o** can't.">` ,
412+ )
413+ }
0 commit comments