How do I embed a single file from a GitHub gist wi

2019-01-30 03:38发布

The new GitHub Gist interface has one embed snippet for the entire gist which embeds all files in the gist. The old interface had embed code for each file in the gist. Anyone know if there's a trick to embed a single file?

标签: github gist
2条回答
Explosion°爆炸
2楼-- · 2019-01-30 04:00

Take the gist URL from the left-hand side and after the .js add a query string like ?file=myFile.blah, e.g.

<script src="https://gist.github.com/4505639.js?file=macroBuild.scala" type="text/javascript"></script>
查看更多
甜甜的少女心
3楼-- · 2019-01-30 04:13

Just for other people reference that might be looking into this.

If you are using Wordpress you may achieve this with the plugin oEmbed-gist and shortcode style:

[gist id="your-gist-id-here" file="your-file-name.js"].

查看更多
登录 后发表回答