Skip to content

Commit

Permalink
add script to fix created dates (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
eshaben authored and nhussein11 committed Jan 8, 2025
1 parent 0cb694f commit a193293
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/fix-created-date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
document.addEventListener('DOMContentLoaded', function () {
const dateLabels = document.querySelectorAll(
'.git-revision-date-localized-plugin-date'
);

// Only make modifications on pages with dates
if (dateLabels.length > 0) {
const lastUpdate = dateLabels[0].innerHTML;
const created = dateLabels[1].innerHTML;

const lastUpdateDate = new Date(lastUpdate);
const createdDate = new Date(created);

// If the created date is after the last updated date,
// default to using the last updated date
if (lastUpdateDate < createdDate) {
dateLabels[1].innerHTML = lastUpdate;
}
}
});

0 comments on commit a193293

Please sign in to comment.