# 更改主题摘录以转到最新帖子而不是特定消息

**URL:** <https://meta.discourse.org/t/change-excerpt-of-topic-to-go-to-latest-post-instead-of-that-specific-message/208148>\
**Category:** Support\
**Created:** [2021年十一月3日 18:54 UTC](https://meta.discourse.org/t/change-excerpt-of-topic-to-go-to-latest-post-instead-of-that-specific-message/208148 "2021-11-03T18:54:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fma965](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fma965/32/259795_2.png) [@Fma965](https://meta.discourse.org/u/Fma965)\
**Post date:** [2021年十一月3日 18:54 UTC](https://meta.discourse.org/t/change-excerpt-of-topic-to-go-to-latest-post-instead-of-that-specific-message/208148/1 "2021-11-03T18:54:11Z")

</div>

我确信有一种非常简单的方法可以做到这一点，但我无法弄清楚。

这是我的主页

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/e/ceab36445bd84973da2e00cd3b3574f407d391a2.jpeg)

如果我点击主题标题（红色框），它会跳转到我上次阅读到的帖子位置。

如果我点击主题消息（黄色框），它会跳转到该特定帖子（即第一个帖子）。

我该如何覆盖这一行为？

---

<div class="post-metadata">

**Author:** ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)\
**Post date:** [2021年十一月4日 03:06 UTC](https://meta.discourse.org/t/change-excerpt-of-topic-to-go-to-latest-post-instead-of-that-specific-message/208148/2 "2021-11-04T03:06:04Z")

</div>

欢迎加入 Meta @Fma965 👋

将此代码添加到 [新主题组件](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966#heading--2-3) 的 `common > header` 选项卡中，然后将该组件添加到您的主题中。

```xml
<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>

```

点击摘要后，用户将被引导至_他们_最后阅读的帖子。

---

<div class="post-metadata">

**Author:** ![Fma965](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fma965/32/259795_2.png) [@Fma965](https://meta.discourse.org/u/Fma965)\
**Post date:** [2021年十一月4日 22:37 UTC](https://meta.discourse.org/t/change-excerpt-of-topic-to-go-to-latest-post-instead-of-that-specific-message/208148/3 "2021-11-04T22:37:43Z")

</div>

非常感谢 🙂 我通过主题组件和 PluginAPI 完成了一些其他操作，但无法解决这个问题。
