html 将私人repo JSON显示为网站内容。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 将私人repo JSON显示为网站内容。相关的知识,希望对你有一定的参考价值。
<script type="text/javascript">
function getUrlVar(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && unescape(result[1]) || "";
}
$ThisPage = getUrlVar('p');
if($ThisPage==''){
$ThisPage = "Home";
}
$token = getUrlVar('t');
var github = new Github({
token: $token,
auth: "oauth"
});
var repo = github.getRepo('kinlane', 'api-commons');
repo.read('master','site.json',function(err, data){
if(!err) {
$Site = jQuery.parseJSON(data);
// Build the navigation
$.each($Site['navigation'], function($key, $value) {
$value = $value + '?p=' + $key + '&t=' + $token;
$NavigationString = '<li><a href="' + $value + '" title="' + $key + '">' + $key + '</a></li>';
$("#primaryNavItems").append($NavigationString);
});
// Build the Page Content
$.each($Site['pages'], function($key, $value) {
if($key==$ThisPage){
$("#pageBody").html($value);
}
});
}
});
</script>
以上是关于html 将私人repo JSON显示为网站内容。的主要内容,如果未能解决你的问题,请参考以下文章