Statiq.Web
Statiq.Web copied to clipboard
Context.GetLink creates a broken link if it includes a #
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.
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 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()
Bumping in case of Wyam resolution ❤️