"Updated last" logic

added the ability to see when the site was last updated
This commit is contained in:
Logen
2024-12-02 23:22:57 -05:00
parent 5e91dbfa1d
commit 51fb02b14e
3 changed files with 20 additions and 2 deletions

View File

@@ -125,3 +125,18 @@ fetch('/parts/footer.html')
})
.catch(error => console.error('Error loading footer:', error));
// Fetch the latest commit information from GitHub
fetch('https://api.github.com/repos/btcforplebs/BTCforPlebs.com/commits/main')
.then(response => response.json())
.then(data => {
const lastUpdate = new Date(data.commit.author.date); // Commit date
const formattedDate = lastUpdate.toLocaleDateString();
const formattedTime = lastUpdate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
// Update the text content of the last-updated-text element
document.getElementById('last-updated-text').textContent = `Website laste updated: ${formattedDate} ${formattedTime}`;
})
.catch(error => {
console.error('Error fetching last update:', error);
document.getElementById('last-updated-text').textContent = 'Last update: Error fetching data.';
});