部落格貼上程式碼

如何匯入 github 的 js 或 css 檔案呢?



1.Github進入檔案位置後,點選Raw會取得檔案路徑(像 https://raw.githubusercontent.com/*/*)






2.將上步驟取得raw file url,利用GitCDN進行轉址:
由於raw檔案並無Content-Type,直接引用會因此產生下列問題:
because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
詳細內容可參閱: mastahyeti 's blog,所以須透過GitCDN來附加Content-Type。
3.將GitCDN取得url,include至HTML中,即可完成引用。
<script src="https://gitcdn.link/repo/google/code-prettify/master/js-modules/run_prettify.js"></script>



留言

SiteTag cloud