Links replace#186
Conversation
|
Welcome @alex-akv! |
|
Hi @alex-akv. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for agent-sandbox ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| - Agent-sandbox installed ([Installation Guide](../../README.md#Installation) | ||
| - JupyterLab deployed ([Installation Guide](./README.md)) | ||
| - Agent-sandbox installed ([Installation Guide](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/README.md#installation)) | ||
| - JupyterLab deployed ([Installation Guide](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/examples/jupyterlab/README.md)) |
There was a problem hiding this comment.
Ideally it should link to the doc in the same commit (instead of main). Would you explain why this change is needed?
There was a problem hiding this comment.
This change is required because the link as is currently does not work on the website (https://agent-sandbox.sigs.k8s.io/docs/guides/jupyterlab/), by changing it to an actual link it ensures that the website sends you to the github link instead of https://agent-sandbox.sigs.k8s.io/docs/INSTALL.md (which it does now), this issue persists everywhere we have this.
|
/ok-to-test |
barney-s
left a comment
There was a problem hiding this comment.
Thanks for fixing the broken links on the documentation site. I understand this change is to make the links work on agent-sandbox.sigs.k8s.io.
However, hardcoding links to the main branch will cause the documentation to be misleading for users browsing older tagged versions. The best long-term solution is to configure the Hugo static site generator to correctly resolve these relative links. For now, could we explore a relative link format that is compatible with Hugo? If not, we should create a follow-up issue to address the documentation build process.
| - Agent-sandbox installed ([Installation Guide](../../README.md#Installation) | ||
| - JupyterLab deployed ([Installation Guide](./README.md)) | ||
| - Agent-sandbox installed ([Installation Guide](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/README.md#installation)) | ||
| - JupyterLab deployed ([Installation Guide](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/examples/jupyterlab/README.md)) |
There was a problem hiding this comment.
While this fixes the link on the rendered website, it makes the documentation less maintainable and potentially misleading for users on different versions. Pinning the link to the main branch means that anyone viewing this document from a tagged release will not see the corresponding version of the installation guide. We should investigate a solution within our static site generator to resolve these links correctly without hardcoding the branch.
There was a problem hiding this comment.
@barney-s, I think I have a solution for this and would like to hear your opinion on it. The solution could be to create a new layout for instance layouts/_default/_markup/render-link.html with contents:
{{- $url := .Destination -}}
{{- $text := .Text -}}
{{- $title := .Title -}}
{{- /* Only rewrite README.md links */ -}}
{{- if or (strings.Contains $url "README.md") (strings.HasSuffix $url "README.md") -}}
{{- /* ../../README.md -> /docs/readme/ (root README) */ -}}
{{- if hasPrefix $url "../../README.md" -}}
{{- $url = "/docs/readme/" -}}
{{- if strings.Contains .Destination "#" -}}
{{- $anchor := index (split .Destination "#") 1 -}}
{{- $url = printf "/docs/readme/#%s" (lower $anchor) -}}
{{- end -}}
{{- /* ./README.md or README.md -> same directory readme */ -}}
{{- else if or (hasPrefix $url "./README.md") (eq $url "README.md") -}}
{{- /* Get parent directory from current page path */ -}}
{{- $pagePath := .Page.File.Dir -}}
{{- $url = printf "/docs/%sreadme/" $pagePath -}}
{{- end -}}
{{- end -}}
<a href="{{ $url | safeURL }}"{{- with $title }} title="{{ . }}"{{ end -}}>{{ $text | safeHTML }}</a>
Where we would keep relative paths as they are, and during hugo build time, the render hook intercepts those links and rewrites them to correct site URLs. I have tested this and it worked successfully.
Some of the tradeoffs would include a requirement for updating the render hook template if hugo URL structure changes.
There was a problem hiding this comment.
SGTM lets do this. If it breaks for old versions we can revisit.
There was a problem hiding this comment.
@barney-s I saw you lgtm'd, but this change hasn't been applied yet
There was a problem hiding this comment.
With this new layout change, the changes to md files must be reverted to use relative paths
There was a problem hiding this comment.
@janetkuo Reverted the links back in the last commit.
|
With this new layout change, the changes to md files must be reverted to use relative paths |
Right! I have reverted the links back in the last commit. |
barney-s
left a comment
There was a problem hiding this comment.
The approach to use a render hook for handling relative links is good. However, I have some concerns about the constructed URLs in the hook implementation and the consistency of changes in the example files.
| ### 1. Deploy Agent-Sandbox to Kind | ||
|
|
||
| You can find agent-sandbox setup instructions [here](../../README.md#installation). | ||
| You can find agent-sandbox setup instructions [here](https://github.com/kubernetes-sigs/agent-sandbox/blob/main/README.md#installation). |
There was a problem hiding this comment.
This change replaces a relative link with an absolute one. Since the goal of this PR (via the render hook) is to support relative links effectively, shouldn't this remain as ../../README.md? The render hook seems designed to handle exactly this case.
There was a problem hiding this comment.
+1 this needs to be reverted as well
| {{- else if or (hasPrefix $url "./README.md") (eq $url "README.md") -}} | ||
| {{- /* Get parent directory from current page path */ -}} | ||
| {{- $pagePath := .Page.File.Dir -}} | ||
| {{- $url = printf "/docs/%sreadme/" $pagePath -}} |
There was a problem hiding this comment.
If .Page.File.Dir returns the path relative to the content directory (e.g., docs/guides/jupyterlab/), prepending /docs/ here might result in a duplicated prefix (e.g., /docs/docs/guides/...). Please verify the value of $pagePath in your environment.
| {{- else if or (hasPrefix $url "./README.md") (eq $url "README.md") -}} | ||
| {{- /* Get parent directory from current page path */ -}} | ||
| {{- $pagePath := .Page.File.Dir -}} | ||
| {{- $url = printf "/docs/%sreadme/" $pagePath -}} |
There was a problem hiding this comment.
Appending readme/ assumes that the referenced README.md is rendered as a page named readme. However, in many cases (like jupyterlab), the README.md content might be served via _index.md (the section index). If so, this link might point to a non-existent page.
| {{- if or (strings.Contains $url "README.md") (strings.HasSuffix $url "README.md") -}} | ||
| {{- /* ../../README.md -> /docs/readme/ (root README) */ -}} | ||
| {{- if hasPrefix $url "../../README.md" -}} | ||
| {{- $url = "/docs/readme/" -}} |
There was a problem hiding this comment.
Similarly, this rewrites ../../README.md to /docs/readme/. Please ensure that the root README.md is indeed served at this specific path and not at /docs/ or another location.
| {{- $url = "/docs/readme/" -}} | ||
| {{- if strings.Contains .Destination "#" -}} | ||
| {{- $anchor := index (split .Destination "#") 1 -}} | ||
| {{- $url = printf "/docs/readme/#%s" (lower $anchor) -}} |
There was a problem hiding this comment.
Using lower is a reasonable default for anchors, but Hugo's ID generation can be complex (e.g., handling spaces, special characters). Ensure this transformation matches the actual IDs generated in the target documents.
|
@barney-s After further investigating and testing based on your latest comments I discovered the core issue was that the
And in this case, the render-links.html script is not needed. The above approach is tested and the result was a success. |
janetkuo
left a comment
There was a problem hiding this comment.
@alex-akv the include-file.html approach sounds good.
Regarding the regex, \]\(\.\/README\.md(#[^)]+)?\) requires the ./ prefix, which means that it will miss links like [Text](README.md), so please adjust the regex to optionalize the ./: \]\((\./)?README\.md(#[^)]+)?\)
…k for langchain readme.
@janetkuo I have pushed the new approach with adjusted regex in commit: af77d87 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alex-akv, barney-s, janetkuo The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
No description provided.