-
Notifications
You must be signed in to change notification settings - Fork 62
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
hugo: Fix anchor links #468
Conversation
👷 Deploy request for cue pending review.Visit the deploys page to approve it
|
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.
@JorindeUsMedia I don't think this PR leaves us in a state where either cue-lang/cue#2971 is fixed; or where we understand what we have to do to avoid it; and where we have on-page examples of things working "correctly" to review and cross-check in the future.
cue-lang/cue#2971 is solely concerned with links to fragments on the same page, when placed inside columns or info/warning/caution blocks. If this issue is demonstrating a workaround for that problem, please can we place some examples on page that show it being fixed (with the use of relref
?).
If this issue isn't demonstrating that, then I'm not sure of its purpose, and I don't think it should close cue-lang/cue#2971.
@@ -23,3 +24,20 @@ The result will be just like a link. But the difference is that with ref/relref | |||
|
|||
[Buttons example]({{< relref "buttons/index.md" >}}) | |||
|
|||
Relref can also be used for anchor links: |
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.
If I'm interpretting this change correctly, please add a note that same-page links to a fragment "must" be invoked via ref
/relref
, if they're to work consistently.
Relref can also be used for anchor links: | ||
|
||
``` | ||
[Anchor links example]({{<ref "#anchor-header" >}}) |
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.
@jpluscplusm It seems Hugo adds the baseUrl in front of all links: also anchor links. |
@jpluscplusm what do I need to do in order to get this pr closed? Mention that is must be used on the examples page? |
I think an explicit mention on the example page that linking to an anchor on the same page requires |
Hm it seems even with using ref instead of regular links there still seems to be an issue with Hugo (or Goldmark) adding the baseUrl in front of the anchor links when used inside of shortcodes.. I'll have to dive into the issue again. |
I think I found it: https://gohugo.io/functions/transform/markdownify/ >
I think we need to use
I will check in which components we use markdownify and change it. I will create a new pr for that |
4a5c2a2
to
b9c0fe8
Compare
Hey @JorindeUsMedia - I've just hit this issue when trying to link to a same-page fragment from inside a |
I've found a solution: see my last comment. I also implemented it but didn't have time to test it yet. I've just updated the pr |
b9c0fe8
to
e88c85a
Compare
a05566e
to
add201c
Compare
I can see changes to several different elements that we use throughout the site. I'm just writing this as a marker that I've seen this PR, but need to find a bit of time to sit down and compare some before-and-after uses of the elements that have been updated :-) |
add201c
to
0826a64
Compare
A manual preview of PR #486 (cue-lang/cuelang.org#468) as the Netlify previews are currently unhappy. Change-Id: I31682a0bccc87ff44347bfa9612c6d0ad54622c5 Signed-off-by: Jorinde Reijnierse <[email protected]> Dispatch-Trailer: {"type":"trybot","CL":1203530,"patchset":1,"ref":"refs/changes/30/1203530/1","targetBranch":"master"}
I've started CI manually, here, as a change we made recently has made the Netlify preview bot unhappy. This is a just a temporary work around until we fix the bot. |
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.
Looks generally good - just a few questions/etc.
I'd like to grab a brief chat to understand the core of what's changing here, so that I can make sure we're marking up anchor links correctly.
ab758eb
to
545f0f4
Compare
- Add example of anchor link using ref to the example/ref page (this is not mandatory to use this way but it can be used like this) - Add working example to Example - Text on how to use custom-id's. - Fix smoothscroll of anchor links that start with the path of the current page (instead of starting with #) - Change markdownify to $.Page.RenderString so anchor links get rendered correctly (recommended by hugo for more complicated markdown which uses the Page context such as anchor links, see highlighted block on https://gohugo.io/functions/transform/markdownify/) . Only tabs still uses markdownify because for some reason RenderString does not work here because it's a partial inside a shortcode. - Change links in example/columns to '/' instead of a non-existing anchor link To test: Go to /examples and test if all the shortcodes are still working as expected. Closes cue-lang/cue#2971 Signed-off-by: Jorinde Reijnierse <[email protected]>
545f0f4
to
d58c3aa
Compare
Preview available at https://cl-1203530-2--cue-cls.netlify.app/. @JorindeUsMedia I've resolved all the threads I feel able to - please could you resolve the rest, and then I'll know it's good for final review? Thank you! |
All resolved :) |
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.
LGTM!
Imported as https://cuelang.org/cl/1203530. |
mandatory to use this way but it can be used like this)
page (instead of starting with #)
correctly (recommended by hugo for more complicated markdown which uses the
Page context such as anchor links, see highlighted block on https://gohugo.io/functions/transform/markdownify/)
. Only tabs still uses markdownify because for some reason RenderString does
not work here because it's a partial inside a shortcode.
To test:
Go to /examples and test if all the shortcodes are still working as expected.
Closes cue-lang/cue#2971