starlight-links-validator icon indicating copy to clipboard operation
starlight-links-validator copied to clipboard

Support expressions in links

Open mierak opened this issue 11 months ago • 3 comments

Is your feature request related to a problem?

Hi! First of all, thank you for the great plugin. It works great for me except in one case:

Currently links get validated (at least in mdx) when they are in their simplest form, for example:

<a href="/some/page">test</a>

however this does not work and the links get ignored and marked as being valid even when they are not:

export const base = "/someBasePath";

<a href={base + "/some/page"}>test</a>

Describe the solution you'd like

It would be great if the plugin is is able to resolve the expression inside the href to its real value and validate it.

Describe alternatives you've considered

No response

Additional Context

No response

mierak avatar Dec 18 '24 19:12 mierak

Thanks for the kind words! Really glad you like it.

With the current architecture, I don't think it's possible to support this use case. A solution could be to move the validation at a later stage altho I'm planning to add more features to the plugin that would prevent this from happening. I'll still investigate this and see if I can come up with a solution.

One question: is the example you provided the only case you're having trouble with, e.g. adding a base to a link? If so, I think this process could be moved to a remark plugin running before the links validator which would allow you to add the base to the links before they're validated.

HiDeoo avatar Dec 21 '24 11:12 HiDeoo

Thanks for the response!

I basically wanted to create a poor man's versioning system, where I would keep two versions of the page, the development and latest release ones, with a common index page. Where creating a new version would involve deleting the old release, copying the current dev version to release version and changing the base in its config file.

So my site would have two bases for two different sections of the web. I have it working in a branch here https://github.com/mierak/rmpc/pull/182 and the base is kept here

mierak avatar Dec 21 '24 12:12 mierak

I see, thanks for the follow-up 🙌 I'll investigate and see if somehow it's a use-case the plugin could support 👍

HiDeoo avatar Dec 21 '24 13:12 HiDeoo