Skip to content

Commit 2934176

Browse files
melissawmdrammock
authored andcommitted
Do not show announcement banner if announcement contents are empty (pydata#1703)
* Do not show announcement banner if announcement contents are empty Also add documentation about updating and removing announcement banners. * dedent * Apply suggestions from code review --------- Co-authored-by: Daniel McCloy <[email protected]>
1 parent b362283 commit 2934176

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/user_guide/announcements.rst

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ For example, the following configuration tells the theme to load the ``custom-te
4141
"announcement": "https://github.com/pydata/pydata-sphinx-theme/raw/main/docs/_templates/custom-template.html",
4242
}
4343
44+
Update or remove announcement banner
45+
------------------------------------
46+
47+
To update or remove the announcement banner, you can change the value of
48+
``html_theme_options["announcement"]`` in your ``conf.py`` or you can edit the
49+
contents of the ``custom-template.html`` file directly. For example, if you have a
50+
temporary announcement that you want to remove without rebuilding your
51+
documentation pages, you can use an empty ``custom-template.html`` file and the
52+
banner will be hidden.
4453

4554
.. _version-warning-banners:
4655

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

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
fetch("{{ theme_announcement }}")
88
.then(res => {return res.text();})
99
.then(data => {
10+
if (data.length === 0) {
11+
console.log("[PST]: Empty announcement at: {{ theme_announcement }}");
12+
return;
13+
}
1014
div = document.querySelector(".bd-header-announcement");
1115
div.classList.add(...{{ header_classes | tojson }});
1216
div.innerHTML = `<div class="bd-header-announcement__content">${data}</div>`;

0 commit comments

Comments
 (0)