Updated script for content

This commit is contained in:
Gregory Hendrickson
2023-06-09 17:07:26 -07:00
parent 48e2f32070
commit 8ea84ca9a4

View File

@@ -1,8 +1,9 @@
window.addEventListener('DOMContentLoaded', async () => { window.addEventListener('DOMContentLoaded', async () => {
const repository = 'ghndrx/docker-test-image'; // Replace with your desired repository const repository = 'ghndrx/docker-test-image'; // Replace with your desired repository
const commitCount = 5; // Number of commits to display
try { try {
const response = await fetch(`https://api.github.com/repos/${repository}/commits`); const response = await fetch(`https://api.github.com/repos/${repository}/commits?per_page=${commitCount}`);
const commits = await response.json(); const commits = await response.json();
const commitList = document.getElementById('commit-list'); const commitList = document.getElementById('commit-list');
@@ -12,8 +13,9 @@ window.addEventListener('DOMContentLoaded', async () => {
const commitElement = document.createElement('div'); const commitElement = document.createElement('div');
commitElement.classList.add('commit'); commitElement.classList.add('commit');
commitElement.innerHTML = ` commitElement.innerHTML = `
<p><strong>${commit.commit.author.name}</strong></p> <p><strong>Commit: </strong>${commit.sha}</p>
<p>${commit.commit.message}</p> <p><strong>Date: </strong>${commit.commit.author.date}</p>
<p><strong>Message: </strong>${commit.commit.message}</p>
`; `;
commitList.appendChild(commitElement); commitList.appendChild(commitElement);
}); });