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

Use relative path for thumbnail image url #695

Closed
1 task done
bfcs opened this issue Dec 10, 2021 · 4 comments
Closed
1 task done

Use relative path for thumbnail image url #695

bfcs opened this issue Dec 10, 2021 · 4 comments
Assignees

Comments

@bfcs
Copy link

bfcs commented Dec 10, 2021

Description

scripts/filters/thumbnail_image_url.js

return urlFor(post.permalink + post.thumbnailImage);

Currently the thumbnail image url is post.permalink + post.thumbnailImage,
e.g. https://username.github.io/2021/12/09/postname/imagename.jpg

When use hexo server to preview locally, there is a 404 error to get the thumbnail image. The image won't show.

image
image

I recommend using relative path for thumbnail image url.
e.g. /2021/12/09/postname/imagename.jpg

Explanation / motivation

To preview locally, solve the 404 error.

Additional information

  • I can implement this feature / improvement

I suggest replace above js code to

return urlFor( new URL(post.permalink).pathname + post.thumbnailImage);

I have tested it and it works ok both locally and Github Page, if you agree, I can make a pull request

@bfcs
Copy link
Author

bfcs commented Dec 11, 2021

the same issue found in generated search result page
source/_js/search-modal.js

 html += '<a class="link-unstyled" href="' + (post.link || post.permalink) + '">';

@LouisBarranqueiro
Copy link
Owner

👋 @bfcs, I would like to help you but I need more information. Could you please fill out the template to report a bug (including versions of your module, hexo, system, etc...)?

@bfcs
Copy link
Author

bfcs commented Dec 14, 2021

Hi, @LouisBarranqueiro ,
The issue is environment independent. When you config the url in _config.yml, the result of post.permalink is https://bfcs.github.io/yyyy/mm/dd/title
image

so
scripts/filters/thumbnail_image_url.js

return urlFor(post.permalink + post.thumbnailImage);

result is https://bfcs.github.io/yyyy/mm/dd/title/thumbnailImage.png

but currently the site haven't deployed, so get the url will return a 404 error.

I suggest use relative path, /yyyy/mm/dd/title/thumbnailImage.png

@LouisBarranqueiro
Copy link
Owner

👋 @bfcs, could you please fill out the template to report a bug (including versions of your module, hexo, system, etc...)? I believe this problem is related to the version of Hexo because it works well on my side. Please re-open this issue when you updated the issue with the information needed.

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

No branches or pull requests

2 participants