Autofill the title
and description
in a LinkCard
#2596
Replies: 1 comment
-
Thanks for the idea! I’m a bit torn on this one. It’s quite easy to do this without modifying Starlight at all with a small custom component, here’s an example: https://stackblitz.com/edit/github-hvevka?file=src%2FAutoLinkCard.astro,src%2Fcontent%2Fdocs%2Findex.mdx So that makes me wonder if baking in this “magic” behaviour is a good idea. It risks begging the question of support for non- Flipside to that is that there are some subtle nuances here like for example fallback content etc. in translated sites that might be hard for people to get perfect if they’re less familiar with the Starlight codebase. So yeah, not 100% sure what’s best. Would be good to hear some more user feedback. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What version of
starlight
are you using?^0.28.6
What is your idea?
Autofill the
title
anddescription
in aLinkCard
when the link is a Starlight page. You would still be able to overwrite it with the props, but it would be handy if they could be autofilled.I wrote a patch (see below) and so am using it in production currently, in my mdx it looks like this:
and rendered looks like:
This is similar to #965 (Generated Index Component), but differs in that it only autofills the title and description for an internal link that you specify. It doesn't attempt to generate a list of these link cards.
Why is this feature necessary?
Reduces duplication in my docs, which is important as when content is still evolving (i.e. not done) having to remember to propagate changes to multiple places is tricky. I often find myself forgetting where stuff has been duplicated, and then have outdated or stale content.
My usecase for using a LinkCard in this way is that, in one of my documentation pages I need to link to related items as a sort of "further reading" and/or "jumping off point" (if you want to leave this doc page before the end, and jump to another part of your learning)
Do you have examples of this feature in other projects?
I just wrote a quick patch for starlight (via
pnpm patch
) that adds this, and it's working well so far. If there is interest I'm happy to send over a PR and properly check it for bugs!patch & my rough implementation idea
Participation
Beta Was this translation helpful? Give feedback.
All reactions