Skip to content

Commit

Permalink
Version warning banner: inject on role="main" or main tag
Browse files Browse the repository at this point in the history
  • Loading branch information
stsewd committed Apr 8, 2021
1 parent ba22f16 commit 9e03f59
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
18 changes: 17 additions & 1 deletion docs/versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,23 @@ you can enable it in the admin section of your docs (:guilabel:`Admin` > :guilab

.. note::

This feature is available only for :doc:`Sphinx projects </intro/getting-started-with-sphinx>`.
The banner will be injected in an HTML element with the ``main`` role or in the ``main`` tag.
For example:

.. code-block:: html

<div role="main">
<!-- The banner would be injected here -->
...
</div>

.. code-block:: html

<main>
<!-- The banner would be injected here -->
...
</main>


Redirects on root URLs
----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ function init(data) {
.attr('href', currentURL)
.text(data.slug);

var body = $("div.body");
if (!body.length) {
body = $("div.document");
var selectors = ['[role=main]', 'main', 'div.body', 'div.document'];
for (var i = 0; i < selectors.length; i++) {
var body = $(selectors[i]);
if (body.length) {
break;
}
}
body.prepend(warning);
}
Expand Down
Loading

0 comments on commit 9e03f59

Please sign in to comment.