问题描述
这个问题似乎令人困惑,所以让我澄清一下.
The question may seem confusing so let me clarify.
Github可让您在存储库中查看文件的源代码.我想将它们包含在iframe中,但不确定如何并且怀疑有人以前已经这样做过.
Github lets you see the source code of a files in a repo. I want to include them in iframes but am unsure how and suspect someone has already done this before.
就我而言,我想添加 https://github .com/ileathan/hubot-mubot/blob/master/src/mubot.coffee 到iframe,以便人们可以从我的网站上看到代码的演变.
In my case I want to add https://github.com/ileathan/hubot-mubot/blob/master/src/mubot.coffee to an iframe so that from my website people can see the code as it evolves.
推荐答案
GitHub页面本身不会直接放在iframe中(由于X-Frame-Options: deny
HTTP标头).
A GitHub page itself wouldn't be put directly in a iframe (because of the X-Frame-Options: deny
HTTP header).
这为您提供了内容的GitHub API
GET /repos/:owner/:repo/contents/:path
例如: https://api.github .com/repos/ileathan/hubot-mubot/contents/src/mubot.coffee .
您应该能够将该内容放入iframe(如该答案所示)
这篇关于有没有办法将github代码嵌入到iframe中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!