博客主题新功能:repl 代码集成

由于 hugo 自 v0.60 之后默认忽略 raw html,所以为了便捷地使用 repl 的 embed code share 功能,我就写了个 shortcode。

效果测试

使用方法

1
2
3
4
5
6
{{< repl "batkiz/hello-repl" >}}

/*
batkiz -> username(不带 `@`)
hello-repl -> repl name
*/

具体的代码则可以去我主题的代码仓库瞅一眼(毕竟非常简单)


2021/05 更新:

repl 已不提供 iframe 嵌入形式的分享选项,不过所幸还没被 ban 掉,官方提供的 iframe 嵌入代码如下所示:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<div class="embed repl">
  <iframe
    class="repl"
    height="400px"
    width="100%"
    src="https://repl.it/@batkiz/hello-repl?lite=true"
    scrolling="no"
    frameborder="no"
    allowtransparency="true"
    allowfullscreen="true"
    sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"
  >
  </iframe>
</div>

只需将 @batkiz/hello-repl 换成你想要的用户名/repl 名。