reactjsdocusaurus

How to link downloadable files in docusaurus?


I want to link downloadable content on my documentation and I tried putting in a link like this:

<a
  href={
    require("@site/static/img/04-api/01/API-Description.png")
      .default
  } download="file-name"
>  download </a>

This generates following html:

<a download="file-name" href="/assets/images/API-Description-6aeb65d8ae136a70b1b5a3d916d27ca0.png">  download </a>

<a download="file-name" href="/assets/images/API-Description-6aeb65d8ae136a70b1b5a3d916d27ca0.png">  download </a>

When I click on the link, I get

"Page Not Found"

I am running version: 2.0.0-beta.17


Solution

  • You had to use inline-html with the download attribute and target="_blank"

    [not working](/logo.png)
    
    <a href={ require("/logo.png").default } download={"origName"}>not working</a>
    
    <a target="_blank" href={ require("/logo.png").default } download>working</a>