Skip to content

Commit f43c8a0

Browse files
authored
EthicalAds: update CSS selector for Material for MkDocs (#579)
The ad was not being displayed correctly because we the CSS was incorrect on pages that are post (Material for MkDocs has a blog plugin now) ## Regular page (same as before) ![Screenshot_2025-05-14_13-05-37](https://github.com/user-attachments/assets/7dd6765f-aadb-4921-9c99-aff2865af386) ## Blog post ![Screenshot_2025-05-14_13-05-48](https://github.com/user-attachments/assets/0c21d9cb-494e-45c3-9415-48f921c087ac) Closes #578
1 parent bf074fc commit f43c8a0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ethicalads.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ export class EthicalAdsAddon extends AddonBase {
119119
knownPlacementFound = true;
120120
}
121121
} else if (docTool.isMaterialMkDocsTheme()) {
122-
selector = ".md-sidebar__scrollwrap";
122+
// Detect the left navbar if it's not hidden or grab the navbar from a post page
123+
selector =
124+
".md-sidebar--primary:not([hidden]) > .md-sidebar__scrollwrap, .md-sidebar--post > .md-sidebar__scrollwrap";
123125
element = document.querySelector(selector);
124126

125127
if (this.elementAboveTheFold(element)) {

0 commit comments

Comments
 (0)