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

Don't trigger download of examples.peggy in docs #546

Open
spenserblack opened this issue Aug 30, 2024 · 6 comments
Open

Don't trigger download of examples.peggy in docs #546

spenserblack opened this issue Aug 30, 2024 · 6 comments
Labels
good first issue Good for newcomers

Comments

@spenserblack
Copy link

When I click on the link that points to js/examples.peggy, my browser triggers a download. Personally, I'd rather read the plain text in my browser, and then I'm free to download it if I want to. Perhaps there's a configuration option to allow this behavior, by recognizing .peggy as plain text?

@hildjj
Copy link
Contributor

hildjj commented Aug 30, 2024

I'll take a PR on this. It's most likely just figuring out the correct URL.

@hildjj hildjj added the good first issue Good for newcomers label Aug 30, 2024
@spenserblack
Copy link
Author

spenserblack commented Aug 30, 2024

Unfortunately I can't seem to reproduce this locally. Both by running the dev server or by building and serving the production build. This could be caused by the deployment server's config.

Edit: nor could I reproduce by accessing a deployment on a Codespace. So it seems to only happen at https://peggyjs.org/, not on any other deployment I've been able to make.

@j4k0xb
Copy link

j4k0xb commented Sep 5, 2024

it's a server issue, should respond with Content-Type: text/plain instead of application/octet-stream for peggy files

https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages#mime-types-on-github-pages

While you can't specify custom MIME types on a per-file or per-repository basis, you can add or modify MIME types for use on GitHub Pages. For more information, see the mime-db contributing guidelines.

@hildjj
Copy link
Contributor

hildjj commented Sep 5, 2024

Yuck. I wish they could get the MIME type from a .gitattributes entry. I guess we could ask them to add .peggy and .pegjs to their mime-db project as text/plain, but they don't have very many things in text/plain at the moment, so I bet they're going to be cautious about adding more.

I wonder if there are any other creative approaches?

@j4k0xb
Copy link

j4k0xb commented Sep 5, 2024

nvm some type starting with application/ would be more appropriate

some workarounds: code block with copy button, change the extension to .txt, serve a html file

@hildjj
Copy link
Contributor

hildjj commented Sep 5, 2024

I could theoretically just assert that an application/x-peggy media type exists, in the docs, then ask them to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants