Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Convert absolute into relative paths #12

Merged
merged 4 commits into from
Dec 22, 2024
Merged

Conversation

PgBiel
Copy link
Contributor

@PgBiel PgBiel commented Dec 22, 2024

Removes all URLs of the form "/css/...", "/index.js", etc., replacing them with "css/...", "index.js".

Without this fix, we can't host the playground in subpaths. For example, hosting it at https://gleam.run/playground would have the website try to access https://gleam.run/index.js, https://gleam.run/css/theme.css and so on, rather than https://gleam.run/playground/index.js and https://gleam.run/playground/css/theme.css. That is, links aren't respecting the base.

This is particularly annoying while testing locally, as the playground might be in a folder. However, this fix is also required for my use case: I'm hosting my customized playground on GitHub Pages, which uses the repository name. Regardless, I believe having the website respect its base is nice and flexible, not to mention that lots of existing path constants were already used in a relative way (such as const prelude in playground.gleam).

The only assumption I make here is that files in static are exported to the same folder where index.html is, as well as precompiled/, which is indeed the case.

I've tested this PR locally with python3 -m http.server on a parent directory (i.e. the playground is available at localhost:8000/public) and all seems to work.

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@lpil lpil merged commit e3db889 into gleam-lang:main Dec 22, 2024
1 check passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants