diff --git a/gatsby-browser.js b/gatsby-browser.js new file mode 100644 index 0000000..8b843ac --- /dev/null +++ b/gatsby-browser.js @@ -0,0 +1 @@ +import "./src/styles/global.css" diff --git a/src/pages/history.js b/src/pages/history.js new file mode 100644 index 0000000..4509192 --- /dev/null +++ b/src/pages/history.js @@ -0,0 +1,53 @@ +import React from "react" +import Header from "../components/header" + +const GIT_NAME = "creyD" +const GIT_REPO = "urban_website" +const GIT_URL = + "https://api.github.com/repos/" + GIT_NAME + "/" + GIT_REPO + "/events" +const GIT_COMMIT_URL = + "https://github.com/" + GIT_NAME + "/" + GIT_REPO + "/commit/" + + +// Adds Git History to the site +function addGitHistory(data) { + for (var push in data) { + for (var commit in data[push]["payload"]["commits"]) { + var new_li = document.createElement("li") + var url = GIT_COMMIT_URL + data[push]["payload"]["commits"][commit].sha + new_li.innerHTML = + data[push]["payload"]["commits"][commit].author.name + + " committed " + + getDate(data[push].created_at) + + ": " + + data[push]["payload"]["commits"][commit].message + + " (Link)" + document.getElementById("log").appendChild(new_li) + } + } +} + +// Send HTTP request to the GitHub API to get information about this repo +const Http = new XMLHttpRequest() +Http.open("GET", GIT_URL) +Http.send() + +// If the API responds call the addGitHistory function +Http.onreadystatechange = function() { + if (this.readyState === 4 && this.status === 200) { + addGitHistory(JSON.parse(Http.responseText)) + } +} + +export default () => ( +
+
+

+ You can see the full commit history{" "} + here. +

+ +
+) diff --git a/src/styles/global.css b/src/styles/global.css new file mode 100644 index 0000000..9db8a87 --- /dev/null +++ b/src/styles/global.css @@ -0,0 +1,3 @@ +html { + background-color: lightgrey; +}