我想使用markdown文件中的链接,单击一下即可下载RPM文件。当我单击链接时,页面将在GitHub上打开。
这是我尝试过的:
<NavButtons
onClick={() => {
const path = AppRoute.ABOUT.replace(':section', 'value');
props.sectionHandler(section)
router.push(path, path, { shallow: true });
}}
/>
第二
| Package | Summery |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| <a href="centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm" download="hello-2.10-1.el8.rpm">hello-2.10-1.el8.rpm</a> | Hello, the rpm binary |
| <a href="centos/8/srpms/hello-2.10-1.el8.src.rpm" download="hello-2.10-1.el8.src.rpm">hello-2.10-1.el8.src.rpm</a> | Hello, the rpm build files |
答案 0 :(得分:1)
在markdown中,链接显示为
[the text to be shown](https link)
所以你可以这样写
[hello-2.10-1.el8.rpm](https://github.com/joergklein/packages/raw/master/centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm)
由于无法在浏览器中打开.rpm,因此将其下载
正如您所说,它打开github页面,尝试添加https://raw.githubusercontent.com而不是https://github.com 然后它将起作用
答案 1 :(得分:0)
您正在使用的相对链接将解析并重定向到特定文件的GitHub页面(请注意,它将重定向到../blob/master/..
)。您需要按如下所示添加带有原始文件链接的markdown(以便它将重定向到../raw/master/..
),以便单击即可下载。
| Package | Summary |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| <a id="raw-url" href="https://github.com/joergklein/packages/raw/master/centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm">hello-2.10-1.el8.rpm</a> | Hello, the rpm binary |
| <a id="raw-url" href="https://github.com/joergklein/packages/raw/master/centos/8/srpms/hello-2.10-1.el8.src.rpm">hello-2.10-1.el8.src.rpm</a> | Hello, the rpm build files |
或者,您也可以使用超链接markdown代替html,如下所示:
| Package | Summary |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| [hello-2.10-1.el8.rpm](https://github.com/joergklein/packages/raw/master/centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm) | Hello, the rpm binary |
| [hello-2.10-1.el8.src.rpm](https://github.com/joergklein/packages/raw/master/centos/8/srpms/hello-2.10-1.el8.src.rpm) | Hello, the rpm build files |