opentofu / registry-ui

Powering the OpenTofu Registry Search (beta)
https://search.opentofu.org
Other
12 stars 4 forks source link

Broken / strange link behaviour #57

Open adamconnelly opened 2 months ago

adamconnelly commented 2 months ago

I've noticed some slightly strange or broken behaviour when trying to use links on the aws_s3_bucket page.

The first problem is that all of the links seem to open a new tab, which is strange when you're navigating to something within the same page or inside the registry. You can see an example of this with the aws_directory_bucket link shown here:

image

When you click on that link, it takes you to an error page instead of to the resource:

image

Another issue is that some links take you back to the HashiCorp registry instead of to the equivalent section in the OpenTofu registry. For example the default_tags configuration block takes you to the HashiCorp registry instead of to the correct anchor:

image

Some links also seem to be slightly wrong, and take you to a page with a .markdown extension. For example this link to aws_s3_bucket_acl:

image

It takes you to a page like this:

image

ghost commented 2 months ago

This is caused because we emit the markdown files as-is without changing any of the links. This is especially a problem when files contain spaces (which we remove).

I believe we need to parse the markdown files and change the links (if relative) to point to the correct files. The frontend then needs to change the links to resolve according to the frontend routing.

abstractionfactory commented 1 month ago

I believe we should resolve this by parsing markdown on the backend and rewriting relative links to match the new URL structure and point to the actual target document. The frontend will have to change links pointing to markdown documents to match its own URL structure, as well as absolute links. We should also pay attention that links with anchors are preserved. This method will make it easier to use the API in other scenarios too.