如何link docusaurus 中的可下载文件?

How to link downloadable files in docusaurus?

我想 link 我的文档中的可下载内容,我试过像这样 link 放置:

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

这会生成以下 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>

当我点击 link 时,我得到

"Page Not Found"

我是运行版本:2.0.0-beta.17

我发现有两个这样做。

首先,将文件放入static文件夹。
示例:./static/image.png.

1) 你的方式

<a href={ require("/image.png").default }>download</a>

2) 简单的方法

[download](/image.png)

** 请注意,我们没有使用 ! 来表示这是一张图片。

您必须将 inline-html 与 download 属性和 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>