如何在“post_1”后添加自定义HTML(第二部分)

不,你需要将这些添加到 CSS 部分。

所以所有内容将整合在一起。

通用 / 头部 :arrow_down:

<script type="text/discourse-plugin" version="0.8">
api.decorateWidget("post:after", helper => {
  const firstPost = helper.attrs.firstPost;
  const h = helper.h;
  if (firstPost) {
    return h("div#custom-ad", [
      h(
        "a.custom-ad-link",
        { href: "example.com" },
        h("img", { src: "https://picsum.photos/id/74/750/90" })
      )
    ]);
  }
});
</script>


通用 / CSS :arrow_down:

#custom-ad {
  .custom-ad-link {
    img {
      width: 100%;
    }
  }
}


桌面端 / CSS :arrow_down:

#custom-ad {
  max-width: calc(45px + 690px + (11px * 2));
}