有人能给个提示,告诉我如何通过 CSS 在标签页隐藏房屋广告吗?谢谢!
无法测试,因为我们不使用标签或内部广告,但可能类似于在 </head> 部分添加以下内容:
<script type="text/discourse-plugin" version="0.8">
api.onPageChange((url) => {
var isTag = /\/tag\//;
if (isTag.test(url) == true) {
document.getElementById("main").classList.add("tag");
}
else {
document.getElementById("main").classList.remove("tag");
}
});
</script>
这会在所有 URL 中包含 /tag/ 的页面(例如 yoursite.com/tag/tag-names)上,为 <section id="main" class="ember-application"> 添加一个类,使其变为 <section id="main" class="ember-application tag">。现在你可以使用 CSS 隐藏包含广告的类,例如:
#main.tag ad-class-you-want-to-hide {
display: none
}