A way to get page type?

Can I get a page type somehow to know if it’s a post page or not? I’m currenly checking if there is a posts-wrapper class cause it’s seems unique for posts, but I’m sure it’s not the best way.

<script type="text/discourse-plugin" version="0.8">
  api.onPageChange(() => {
    $(document).ready(() => {
      if ($(".posts-wrapper").length) {
        //run script if it is a post
      }
    });
  });
</script>
1 Like

I believe the body has a class: archetype-regular.
archetype-private_message for direct messages.

4 Likes

Thanks, looks better!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.