Skip to content

Commit

Permalink
EthicalAd: specific placement for Antora and mdBook (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Jan 22, 2025
1 parent 24287b8 commit 1a729a4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ We maintain a list of examples to check our JavaScript client is working correct
* `Docusaurus <https://test-builds.readthedocs.io/en/docusaurus/>`_
* `Jekyll <https://test-builds.readthedocs.io/en/jekyll/>`_
* `Jupyter Book <https://test-builds.readthedocs.io/en/jupyter-book/>`_
* `mdBook <https://test-builds.readthedocs.io/en/mdbook/>`_
* `MkDocs <https://test-builds.readthedocs.io/en/mkdocs/>`_
* `MkDocs (Material theme) <https://test-builds.readthedocs.io/en/mkdocs-material/>`_
* `MkDocs (Terminal theme) <https://test-builds.readthedocs.io/en/mkdocs-terminal/>`_
Expand Down
9 changes: 9 additions & 0 deletions src/doctools.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,37 @@
* values.
**/
@layer defaults {
:root[data-readthedocs-tool="docusaurus"] {
--readthedocs-flyout-header-font-size: 0.9rem;
}

:root[data-readthedocs-tool="mkdocs-material"] {
--readthedocs-font-size: 0.58rem;
--readthedocs-flyout-header-font-size: 0.7rem;
--readthedocs-flyout-font-size: 0.58rem;
}

:root[data-readthedocs-tool="antora"] {
--readthedocs-font-size: 0.7rem;
--readthedocs-flyout-header-font-size: 0.8rem;
--readthedocs-flyout-font-size: 0.7rem;
}

:root[data-readthedocs-tool="mdbook"] {
--readthedocs-font-size: 1.3rem;
--readthedocs-flyout-header-font-size: 1.5rem;
--readthedocs-flyout-font-size: 1.3rem;
}

:root[data-readthedocs-tool="sphinx"][data-readthedocs-tool-theme="furo"] {
--readthedocs-font-size: 0.725rem;
--readthedocs-flyout-header-font-size: 0.845rem;
--readthedocs-flyout-font-size: 0.725rem;
}

:root[data-readthedocs-tool="sphinx"][data-readthedocs-tool-theme="immaterial"] {
--readthedocs-font-size: 0.58rem;
--readthedocs-flyout-header-font-size: 0.7rem;
--readthedocs-flyout-font-size: 0.58rem;
}
}
22 changes: 22 additions & 0 deletions src/ethicalads.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@ export class EthicalAdsAddon extends AddonBase {
placement.classList.add("ethical-alabaster");
placement.classList.add("ethical-docsify");

placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("data-ea-style", "image");
knownPlacementFound = true;
}
} else if (docTool.isAntora()) {
selector = "aside nav.nav-menu";
element = document.querySelector(selector);

if (this.elementAboveTheFold(element)) {
placement.classList.add("ethical-alabaster");

placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("data-ea-style", "image");
knownPlacementFound = true;
}
} else if (docTool.isMdBook()) {
selector = "nav#sidebar mdbook-sidebar-scrollbox";
element = document.querySelector(selector);

if (this.elementAboveTheFold(element)) {
placement.classList.add("ethical-alabaster");

placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("data-ea-style", "image");
knownPlacementFound = true;
Expand Down

0 comments on commit 1a729a4

Please sign in to comment.