Skip to content

Commit 26abd90

Browse files
authored
Don't show announcement banner if html is empty
1 parent 11af3fc commit 26abd90

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
fetch("{{ theme_announcement }}")
88
.then(res => {return res.text();})
99
.then(data => {
10-
div = document.querySelector(".bd-header-announcement");
11-
div.classList.add(...{{ header_classes | tojson }});
12-
div.innerHTML = `<div class="bd-header-announcement__content">${data}</div>`;
10+
if (data.length === 0) {
11+
console.log("[PST]: Empty announcement at: {{ theme_announcement }}");
12+
return;
13+
} else {
14+
div = document.querySelector(".bd-header-announcement");
15+
div.classList.add(...["bd-header-announcement", "container-fluid"]);
16+
div.innerHTML = `<div class="bd-header-announcement__content">${data}</div>`;
17+
}
1318
})
1419
.catch(error => {
1520
console.log("[PST]: Failed to load announcement at: {{ theme_announcement }}");

0 commit comments

Comments
 (0)