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

Blog authors page is not using baseUrl when rendering a relative author.image_url #10434

Closed
2 of 7 tasks
laliconfigcat opened this issue Aug 22, 2024 · 5 comments · Fixed by #10440
Closed
2 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@laliconfigcat
Copy link

laliconfigcat commented Aug 22, 2024

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

It seems to me that author.image_url is not prepended with the baseUrl so the images are not shown correctly for relative images. In the blog posts the relative image url is working (I think it was fixed with this issue: #9577).
image
image

Reproducible demo

No response

Steps to reproduce

  1. create a site with baseUrl
  2. add an author with relative image_url
  3. check the generated code for the image on the authors page and on the dedicated author pages.

Expected behavior

The images associated with authors to be rendered correctly.

Actual behavior

The images associated with authors are not rendered correctly.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.
@laliconfigcat laliconfigcat added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Aug 22, 2024
@laliconfigcat laliconfigcat changed the title Blog authors page is not using baseUrl when rendering the author.image_url Blog authors page is not using baseUrl when rendering a relative author.image_url Aug 22, 2024
@OzakIOne OzakIOne removed the status: needs triage This issue has not been triaged by maintainers label Aug 23, 2024
@slorber
Copy link
Collaborator

slorber commented Aug 26, 2024

@laliconfigcat can you please be more concrete and provide an actual example/repro?

We have a PR fix (#10440) but since the bug is quite abstract we are not 100% sure it will fix your case.

  • What do you mean by "relative image", is this ./image.png or /image.png
  • Where is the image located in the file system
  • What's the actual URL of the <img> tag (the one that fails to load)
  • What's the expected URL of the <img> tag (the one that would be able to load)

Thanks


For now the PR assumes your author image is probably in /static/ and referenced with a URL starting with /. The PR won't cover URLs like ./author.png with the image co-located to the authors.yml file

@laliconfigcat
Copy link
Author

Hello @slorber ,

Thanks for getting back to me.

I created a small repro app following these steps:
1: npx create-docusaurus@latest my-website classic
2: change the baseUrl to '/baseUrl' in docusaurus.config.ts
3: change the image_url to /img/docusaurus.png in authors.yml

If you open a blog post, or if you open the blog main page, the author images will be fine (the image url is /baseUrl/img/docusaurus.png), but if you click on the author direct page or the author listing page, the image will not be shown (the url is /img/docusaurus.png).

I tried it with ./img/docusaurus.png too in the authors.yml, but it didn't compile that way. My images are in the static folder, so I hope the PR will solve my problem too.

You can find the repro app here: https://github.com/laliconfigcat/author-repro.

@slorber
Copy link
Collaborator

slorber commented Aug 26, 2024

I see thanks

The problem is adding something like this to authors.yml:

slorber:
  name: Sébastien Lorber
  image_url: /img/docusaurus.png

The PR will fix it yes

@laliconfigcat
Copy link
Author

Many thanks for the fix! I'm looking forward to it, as the new features are awesome!
Do you happen to know when we can expect a new release with the fix?

@slorber
Copy link
Collaborator

slorber commented Sep 12, 2024

thanks @laliconfigcat

You can already use a canary version, it's relatively safe to adopt in production, it's just v3.5 with a few extra well-tested commits.

Otherwise I don't plan to release v3.6 until I merge this one but it's going to take a few more weeks: #10402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants