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

gatsby-source-filesystem's publicURL should keep file name #22244

Closed
KoltesDigital opened this issue Mar 13, 2020 · 4 comments · Fixed by #22328
Closed

gatsby-source-filesystem's publicURL should keep file name #22244

KoltesDigital opened this issue Mar 13, 2020 · 4 comments · Fixed by #22328
Labels
help wanted Issue with a clear description that the community can help with.

Comments

@KoltesDigital
Copy link
Contributor

Summary

Change the file publicURL pattern from ${file.name}-${file.internal.contentDigest}${details.ext} to ${file.internal.contentDigest}/${file.base}.

const fileName = `${file.name}-${file.internal.contentDigest}${details.ext}`

Motivation

My concern is that files which should be downloaded are renamed, and visitors shouldn't know about that.

Right now, if I'm giving a link to say Brand-ProductCatalog.pdf, the link actually points to /static/Brand-ProductCatalog-f4c0ceb6e2839acca98c07d3839833e4.pdf, and this looks weird if someone downloads it and see the digest in their finder.

If instead I'm putting the link in a .md file, thanks to gatsby-remark-copy-linked-files the path is /static/f4c0ceb6e2839acca98c07d3839833e4/Brand-ProductCatalog.pdf which is what I want: the filename isn't changed.

But I want to do it directly, without having to put the link in a .md file.

This problem was mentioned at #9777 (comment) but I can't find a commit that changes this.

@KoltesDigital
Copy link
Contributor Author

Well, even though the link href is exactly the same, the manual link opens the 404 page, and when the browser reloads it opens the PDF (using the component Link imported from gatsby), whereas with the Markdown link the PDF opens directly. And I can't see any hook in the code.

@KoltesDigital
Copy link
Contributor Author

Ah I shouldn't use Link actually. It makes sense. Using a instead, both work fine.

I can make a PR if you want. It's only about this single line.

@LekoArts LekoArts added the help wanted Issue with a clear description that the community can help with. label Mar 16, 2020
@LekoArts
Copy link
Contributor

We'd appreciate a PR fixing this. Thanks a lot!

@KoltesDigital
Copy link
Contributor Author

Here's the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants