爱意满满的作品展示区。
SaulLawliet
0.01D

为什么 Gist 有 Embed 可以在其他页面引用,而 Github 仓库里的代码没有?所以自己创造。

  •  
  •   SaulLawliet ·
    SaulLawliet · Sep 5, 2015 · 3390 views
    This topic created in 3982 days ago, the information mentioned may be changed or developed.

    功能大概是在文章里通过js展示 Github 上的代码. 当代码更新了, 不必更新文章, 更新此项目即可.

    这是一个笨方法实现, 具体是用shell生成展示某代码的js, 然后上传到 Github, 最后在页面里引用此js

    详细介绍请戳Github 链接

    5 replies    2015-09-06 14:46:47 +08:00
    oott123
        1
    oott123  
       Sep 5, 2015   ❤️ 1
    为什么不用 GitHub API 呢?这样不用手动生成,同时也不需要把不必要的文件加到 repo 里。
    https://api.github.com/repos/SaulLawliet/gist-it/contents/gist-it.sh
    oott123
        2
    oott123  
       Sep 5, 2015
    随便写了下,大概这样: http://runjs.cn/detail/uqluzvvm
    就是没高亮,得加个其它的高亮组件。
    SaulLawliet
        3
    SaulLawliet  
    OP
       Sep 6, 2015
    @oott123 原来 API 是这么用的, 感谢.
    其实我就是 copy 了 Gist Embed 的做法
    oott123
        4
    oott123  
       Sep 6, 2015
    你这样太 dirty 了,不够优雅……
    SaulLawliet
        5
    SaulLawliet  
    OP
       Sep 6, 2015
    @oott123 (T T)是啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2765 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 04:34 · PVG 12:34 · LAX 21:34 · JFK 00:34
    ♥ Do have faith in what you're doing.