Change Excerpt of topic to go to latest post instead of that specific message

Welcome to Meta @Fma965 :wave:

Add this to the common > header tab of a new theme component, then add that component to your theme.

<script type="text/discourse-plugin" version="0.8">
const { on } = require("discourse-common/utils/decorators");

api.modifyClass("component:topic-list-item", {
  @on("didInsertElement")
  _changeExcerptLink() {
    const excerptLink = this.element.querySelector(".topic-excerpt");
    if (excerptLink) {
       excerptLink.href = this.topic.lastReadUrl 
    }
  }
});
</script>

Clicking the excerpt will then take the user to their last read post.

1 Like