Skip to content

Same file + extension in directory names breaks relative image assets #8921

@kaspar-p

Description

@kaspar-p

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

When referencing static images that are colocated with alongside the Markdown file, if the directory name has <filename>.md in it, the image can't be found.

For example, a file like file.md, with a nearby directory called file.md__static_image_assets__, will break. It attempts to find the file in the global /static folder, even if the path in file.md is like:

[some image](./file.md__static_image_assets/image.png)

This is a legal directory name, so this should work.

Reproducible demo

https://stackblitz.com/edit/github-znyym6?file=docs/file.md

Steps to reproduce

  1. See the reproduction:
  2. Have a folder in docs/ called file.md__static_image__assets with an image.png image in it.
  3. Have a file.md in docs/ with content of something like
![my image](./file.md__static_image_assets__/image.png)
  1. Verify it won't compile.

Expected behavior

Should compile.

Actual behavior

Doesn't compile, looks for the image in /static.

Your environment

Public source code: https://stackblitz.com/edit/github-znyym6?file=docs/file.md

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

Labels

bugAn error in the Docusaurus core causing instability or issues with its executiondomain: markdownRelated to Markdown parsing or syntax

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions