Skip to content
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

Fix relative URLs when serving the specification with a custom baseURL #1984

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

zecakeh
Copy link
Contributor

@zecakeh zecakeh commented Oct 24, 2024

Requires matrix-org/docsy#4.

Using canonifyURLs and a baseURL that is not / at the same time makes .RelPermalink and relref return relative URLs where the first path segment is duplicated, e.g. /v1.11/v1.11/rest/of/the/path.

canonifyURLs is deprecated so let's get rid of it and allow Hugo to compute the relative URLs itself, because it keeps track of the resources and knows where they will be served.

This can be reviewed commit by commit.

Since the PR CI uses / as a baseURL, I guess the only way to test that this works before it is deployed is to generate the spec locally with a custom baseURL like /v1.11 and make sure that there are no URLs where it is duplicated.

Closes #1957.
Fixes the causes behind #1964, but the artifacts that were already generated for v1.11 and v1.12 still need to be fixed somehow.

Pull Request Checklist

Preview: https://pr1984--matrix-spec-previews.netlify.app

@zecakeh zecakeh requested a review from a team as a code owner October 24, 2024 10:34
@zecakeh zecakeh marked this pull request as draft October 24, 2024 13:27
@zecakeh
Copy link
Contributor Author

zecakeh commented Oct 24, 2024

Leaving as a draft for now, it turns out that it creates broken links in places (see CI).

All the broken links are declared as only a fragment. For some of them, it's good that they are broken, because the need at least the spec path, otherwise it means that they are also broken in the generated OpenAPI definitions. But other fragments should just work, like the ones inside info boxes.

@zecakeh
Copy link
Contributor Author

zecakeh commented Oct 24, 2024

Alright the issues have been fixed, but I am leaving this as a draft for now until the docsy PR is merged.

So the good news is that now some links that would have been broken in the OpenAPI definitions are also broken in the rendered spec, and we detect them in CI thanks to htmltest.

Signed-off-by: Kévin Commaille <[email protected]>
Helps Hugo to generate the correct links for files in /static.

Signed-off-by: Kévin Commaille <[email protected]>
It is deprecated and messes with relative links when used with some baseURLs.

Signed-off-by: Kévin Commaille <[email protected]>
Now that relative links are fixed, having it enabled is not a problem anymore.

Signed-off-by: Kévin Commaille <[email protected]>
Signed-off-by: Kévin Commaille <[email protected]>
Otherwise the `relref` in the changelogs does not work.
Version 0.124.1 is the last version of Hugo to work with the current
version of the docsy theme.

Signed-off-by: Kévin Commaille <[email protected]>
This causes issues for links as the method doesn't have
the right context to resolve them.
The content is already markdownified because of the `%` syntax of the shortcode
that calls it, and it has the right context.

Signed-off-by: Kévin Commaille <[email protected]>
Links that contain only a fragment are not resolved by Hugo so the final relative URL is wrong.
They also cause problems for the OpenAPI definitions because these links are
not edited in the dump-openapi script so they end up broken.

Signed-off-by: Kévin Commaille <[email protected]>
@zecakeh zecakeh marked this pull request as ready for review November 1, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop using canonifyURLs
1 participant