-
Notifications
You must be signed in to change notification settings - Fork 396
feat: Add target attribute to links in listing templates if provided #12293
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
base: main
Are you sure you want to change the base?
feat: Add target attribute to links in listing templates if provided #12293
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
cderv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the addition.
If I see the value of the feature, I am wondering if this is best field name. target is a bit broad when you don't know about the usage.
And it opens also question for other link attribute. For example, with target="_blank" you usually want to add rel="noopener noreferrer" for security.
It fiels a bit weird to have such fields that controls listing links rededring at top level.
But that is just first impression here. I am thinking about better organization or naming.
For example, what if need to allow aria-label addition for those link ? if it should be controlled by user, it would be another field ?
I wonder if we should have something closer to manuscript code-links
https://quarto.org/docs/manuscripts/components.html#code-links
listing-link:
target: "_blank"
rel: "noopener noreferrer"
aria-label: "Opens in new window"
This would allow adding schema maybe.
Also, doc related: this is kind of a special metadata field that needs to go into the list of known ones
https://quarto.org/docs/websites/website-listings.html#listing-fields
I think it is good to always have doc in mind which each PR.
This is the kind of PR that seems simple to fix, but requires some thinking for best long term behavior.
Regarding code review, you need to be thorough. I believe if you add a field to template you need to update that part too
| // Fields | |
| const fields = listing.fields; | |
| // Image properties | |
| const imageAlign = listing['image-align'] || 'left'; | |
| const imageHeight = listing['image-height']; | |
| // Fields that don't have a known place to be displayed in this template | |
| const otherFields = fields.filter(field => { | |
| return !["title", "image", "image-alt", "date", "author", "subtitle", "description", "reading-time", "categories"].includes(field); | |
| }); |
Otherwise the field will end up in a metadata-value div, which I don't think we want here right ?
Anyhow, open to discussion.
|
You're right that
|
This PR is one year old and as you pointed needs a bit of discussion to generalise it (also why I initially added the label). Few notes:
|
Yes, that is why sometimes a feature that seems nice and easy to do can lead to more design question, and more thoughts needed. Generally why contributed feature PR takes time to review and think about. |
Enhance the listing templates by conditionally adding a target attribute to links.
This allows for better control over link behaviour, enabling users to open links in new tabs if specified.
Screen.Recording.2025-03-14.at.21.43.08.mov
Originally discussed in: