Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid a website listing parsing an invalid thumbnail image from an empty meta image of its item which does not even consider it as a preview image #12222

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/project/types/website/listing/website-listing-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ async function listItemFromFile(
descriptionPlaceholder(inputTarget?.outputHref, maxDescLength);

const imageRaw = documentMeta?.image as string | boolean;
const image = imageRaw !== undefined && typeof imageRaw === "string"
const image = imageRaw && typeof imageRaw === "string"
? pathWithForwardSlashes(
listingItemHref(imageRaw, dirname(projectRelativePath)),
)
Expand Down
21 changes: 21 additions & 0 deletions tests/docs/smoke-all/2025/03/07/issue-12222/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project:
type: website

website:
title: "myblog"
twitter-card: true
open-graph: true
page-footer:
center: |
Footer image:
[![](/profile.jpg)](https://quarto.org/)
navbar:
right:
- icon: github
href: https://github.com/
- icon: twitter
href: https://twitter.com

format:
html:
theme: cosmo
15 changes: 15 additions & 0 deletions tests/docs/smoke-all/2025/03/07/issue-12222/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "Listing Example"
listing:
contents: posts
sort: "date desc"
_quarto:
render-project: true
tests:
html:
ensureFileRegexMatches:
-
- '\<img src="posts[/|\\]post-with-code[/|\\]image.jpg'
- '\<img src="posts[/|\\]welcome[/|\\]thumbnail.jpg'
- []
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
date: '2025-03-06T14:38:55+09:00'
title: "Yes, meta image but empty"
_quarto:
render-project: true
tests:
html:
ensureFileRegexMatches:
-
- '\<meta name="twitter:image" content="../..[/|\\]posts/welcome/thumbnail.jpg'
- '\<meta property="og:image" content="../..[/|\\]posts/welcome/thumbnail.jpg'
- []
image: ""
---

Testing images.

![](/posts/welcome/thumbnail.jpg)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
date: '2025-03-06T14:38:55+09:00'
title: "This has no meta image"
_quarto:
render-project: true
tests:
html:
ensureFileRegexMatches:
-
- '\<meta name="twitter:image" content="../..[/|\\]posts/post-with-code/image.jpg'
- '\<meta property="og:image" content="../..[/|\\]posts/post-with-code/image.jpg'
- []
---

Testing images.

![](/posts/post-with-code/image.jpg)
Loading