Statiq.Web icon indicating copy to clipboard operation
Statiq.Web copied to clipboard

Context.GetLink creates a broken link if it includes a #

Open SilentSin opened this issue 5 years ago • 3 comments

In my custom _Navbar.cshtml:

Context.GetLink("docs/introduction#frequently-asked-questions") creates a broken link. Firefox shows it correctly in the bottom corner, but when clicking on it the # gets replaced by %23 in the address bar and it doesn't work.

Context.GetLink("docs/introduction") + "#frequently-asked-questions" works though.

SilentSin avatar Nov 10 '18 12:11 SilentSin

Inside the GetLink Method UriBuilder is used with the Path property. To add the part after the hash in an unencoded way the Fragment property from UriBuilder must be used.

I think to make this work for every case another overload for GetLink must be created with Fragment parameter. @daveaglick should we add something like this?

schulz3000 avatar Nov 15 '18 19:11 schulz3000

@schulz3000 you’ve got the measure of it. We’d probably need an overload that can take the fragment. Not sure I want to invest in that right now though since there’s a workaround.

I’m planning on working snippets (#359) into the work for vNext right after 2.0 ships. Been wanting to get that done for a while. That’ll let us generate links anywhere, including Markdown, with syntax like %%link:docs/introduction#anchor (exact syntax TBD). I’ll leave this issue open to make sure fragments work for the link snippet when I get that far (and if it looks like that’s going to take a while, then we can circle back and add a fragment overload to .GetLink()

daveaglick avatar Nov 19 '18 21:11 daveaglick

Bumping in case of Wyam resolution ❤️

aycippo avatar May 19 '23 23:05 aycippo