Show HN:在你的网站上嵌入真实的 Linux 终端
Show HN: Embed a real Linux terminal on your website

原始链接: https://sandbox.bio/training/embed

您可以轻松地将交互式 `sandbox.bio` 终端嵌入到您的网站或博客中,从而在浏览器中直接执行命令。 若要开始使用,请将以下脚本标签添加到您的页面: `` 集成后,您的 `bash` 代码块(在 GitHub Pages Markdown 或标准的 `language-bash` HTML div 中)将自动出现一个“运行”按钮。 **自定义选项包括:** * **`data-cwd`**:设置初始工作目录。 * **`data-config`**:指向一个远程 JSON 文件,用于进行高级终端配置。 您还可以通过在配置文件中使用 `tools` 数组来预加载特定文件,以便用户进行交互。该数组需指定文件 URL 以及文件在终端中显示的本地路径。这是为您的技术内容创建交互式教程或演示的高效方式。

对不起。
相关文章

原文

Embed sandbox.bio

Add a live terminal to your website or blog post

You can embed a sandbox.bio terminal directly on your website or blog post. Simply add this script tag to your page:

<script src="https://sandbox.bio/embed.js" data-cwd="embed"></script>
A blog post with Run buttons on its code blocks and a terminal docked at the bottom

If you use GitHub Pages, any Markdown code blocks you mark as ```bash will have a "Run" button that executes directly in the embedded terminal. For HTML websites, any <div> with the class "language-bash" will get a "Run" button.

You can also customize the embedded terminal by adding attributes to the script tag:

  • data-cwd="folder-name": the starting working directory in the terminal
  • data-config="https://yourwebsite.com/config.json": an optional remote config URL, using the same format as the sandboxbio.config.json file used by the GitHub integration. This file can be hosted on GitHub Pages too.

If you need to preload files in the terminal, you can use the array files inside your config, and specify the URLs to where each file lives:

{
  tools: [
    { "url": "https://<username>.github.io/<repo>/data/example.bam", "path": "example.bam" }
  ]
}
联系我们 contact @ memedata.com