Using Github Repository metadata with Jekyll & Javascript

做~自己de王妃 提交于 2019-12-11 04:16:33

问题


I have been following the article Github Metadata with Jekyll and JavaScript which mentions how to use Github Repository Metadata using Jekyll and Javascript.

The article there says that you need to add the following to index.html before the link to an external JS file. Now repos is globally available so you can use it in our external JS file.

<script>
  var repos = {{ site.github.public_repositories | jsonify }};
</script>

I have created an index.html file which contains the following contents.

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>GitHub Repository</title>
</head>
<body>

<script>
  var repos = {{ site.github.public_repositories | jsonify }};
</script>

<script src="https://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="github-repo.js"></script>

</body>
</html>

github-repo.js

$(document).ready(function(){
  console.log(repos);
});

But, when I run the code I get Uncaught ReferenceError: repos is not defined error

来源:https://stackoverflow.com/questions/38559218/using-github-repository-metadata-with-jekyll-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!