# 如何在所有主题中添加主题摘要

**URL:** https://meta.discourse.org/t/how-to-add-topic-excerpt-to-all-my-topics/148903
**Category:** Development
**Created:** [2020年四月22日 20:07 UTC](https://meta.discourse.org/t/how-to-add-topic-excerpt-to-all-my-topics/148903 "2020-04-22T20:07:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![duranmla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/duranmla/32/109295_2.png) [@duranmla](https://meta.discourse.org/u/duranmla)
#### Post date: [2020年四月22日 20:07 UTC](https://meta.discourse.org/t/how-to-add-topic-excerpt-to-all-my-topics/148903/1 "2020-04-22T20:07:34Z")

</div>

大家好，

在稍微折腾一下 Discourse 后，我意识到只有置顶话题才会携带 `excerpt` 属性。虽然我可以更新话题的序列化器来添加这个 `excerpt` 属性，但我希望能避免修改后端代码，因为那样维护起来比仅修改前端更困难。

我的问题是：  
**置顶话题与普通话题之间有什么区别，使得只有置顶话题能显示摘要（excerpt）？**

一图胜千言。[这是我在最新页面中的本地环境](https://meta.discourse.org/uploads/short-url/pDCE8CIyAw0H5ZhzPqZ054JN5BK.png)，如您所见，只有置顶话题显示了摘要。 **为什么？以及我该如何通过 Discourse 主题来修改这一点？**

我认为假设“这不可能实现”是不对的，因为这些摘要是当我们置顶话题时才被启用的。我想我需要 **调整“发现话题”页面执行的查询** ，使其始终请求摘要……但说实话，即使有一些折腾 Discourse 的经验，我仍然难以理解其中的数据流。

_如果有说明 Discourse 数据流如何工作的文档，那将非常有帮助。_

非常感谢！！

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2020年四月22日 20:27 UTC](https://meta.discourse.org/t/how-to-add-topic-excerpt-to-all-my-topics/148903/2 "2020-04-22T20:27:11Z")

</div>

主题现在可以选择支持摘要了！这是一个非常近期的变更，我认为我们尚未在指南中对此进行文档记录。

在此查看示例：

[https://github.com/discourse/Fakebook/commit/bc9147c960f0335d7e6efc2127424227f5ef8132](https://github.com/discourse/Fakebook/commit/bc9147c960f0335d7e6efc2127424227f5ef8132)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年四月22日 20:37 UTC](https://meta.discourse.org/t/how-to-add-topic-excerpt-to-all-my-topics/148903/3 "2020-04-22T20:37:58Z")

</div>

非常好，@Falco

我正准备回复 Alexis，但看到你们在输入。

稍微回答一下他的普遍性问题：数据的包含通常由当前使用的序列化器决定。

当我去查看这个示例时，发现：[discourse/app/serializers/listable\_topic\_serializer.rb at 094ddb1c1ffcd305e841dfa1efd6981507519054 · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/094ddb1c1ffcd305e841dfa1efd6981507519054/app/serializers/listable_topic_serializer.rb#L3)

具体是：

```plaintext
  def include_excerpt?
    pinned || SiteSetting.always_include_topic_excerpts || ThemeModifierHelper.new(request: scope.request).serialize_topic_excerpts
  end

```

这基本上已经说明了一切 🙂

---

<div class="post-metadata">

### Author: ![duranmla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/duranmla/32/109295_2.png) [@duranmla](https://meta.discourse.org/u/duranmla)
#### Post date: [2020年四月24日 15:40 UTC](https://meta.discourse.org/t/how-to-add-topic-excerpt-to-all-my-topics/148903/4 "2020-04-24T15:40:36Z")

</div>

非常抱歉这么晚才来加入对话说声谢谢！哈哈哈。不过还是要非常感谢你们这么快就回应了，我一看你们发帖就读了，但当时我在用手机，没法登录平台。谢谢！😊

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [2022年六月20日 10:13 UTC](https://meta.discourse.org/t/how-to-add-topic-excerpt-to-all-my-topics/148903/5 "2022-06-20T10:13:06Z")

</div>

对于通过搜索找到此主题的任何人，您现在可以使用：[Topic List Excerpts](https://meta.discourse.org/t/topic-list-excerpts-theme-component/151520?u=jonathan5)
