"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

@@ -343,7 +343,7 @@ html {
padding: 10px 10px;
font-size: 16px;
cursor: pointer;
margin: auto auto auto auto;
margin: auto auto auto 10px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
text-align: center;
line-height: 1.5em;

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.';
});

View File

@@ -74,7 +74,10 @@
<a href="https://github.com/btcforplebs/BTCforPlebs.com" target="_blank" title="GitHub" class="prefetch">
<i class="fa-solid fa-github"></i>
</a>
</div>
</div>
<div class="last-update">
<small id="last-updated-text"></small>
</div>
</div>
</div>
<div id="footer"></div>