Skip to content

Commit 2cd0642

Browse files
authored
Hide announcement with JS if date is past (#556)
1 parent e095456 commit 2cd0642

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

docs/assets/overrides/main.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,36 @@
1616
></span>
1717
</a>
1818
</div>
19-
{% if not config.extra.announcement.active %}
2019
<style type="text/css">
2120
.md-banner {
2221
display: none;
2322
}
2423
</style>
24+
{% if config.extra.announcement.active %}
25+
<script>
26+
(function () {
27+
function hideAnnouncement() {
28+
var announcementDate = new Date(
29+
"{{ config.extra.announcement.hide_after }}T00:00:00Z",
30+
);
31+
var currentDate = new Date();
32+
var banner = document.querySelector(".md-banner");
33+
if (banner && currentDate <= announcementDate) {
34+
banner.style.display = "block";
35+
}
36+
}
37+
38+
// Run on initial load
39+
hideAnnouncement();
40+
41+
// Hook into XHR to run after each page update
42+
var originalOpen = XMLHttpRequest.prototype.open;
43+
XMLHttpRequest.prototype.open = function () {
44+
this.addEventListener("load", function () {
45+
setTimeout(hideAnnouncement, 0); // Ensure it runs after the request completes
46+
});
47+
return originalOpen.apply(this, arguments);
48+
};
49+
})();
50+
</script>
2551
{% endif %} {% endblock %}

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ extra:
117117
text_bold: March 10-14, 2025
118118
url: https://community.seqera.io/t/nextflow-training-week-2025-q1/1775/6
119119
url_text: More info
120+
hide_after: 2025-03-15
120121
# Analytics
121122
analytics:
122123
provider: google

0 commit comments

Comments
 (0)