# 仿Facebook主题

**URL:** https://meta.discourse.org/t/fakebook-theme/109079
**Category:** Theme
**Tags:** official, fakebook-theme
**Created:** [2019年二月13日 20:18 UTC](https://meta.discourse.org/t/fakebook-theme/109079 "2019-02-13T20:18:45Z")
**Posts on this page:** 1
**Showing post:** 86

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [2020年十一月24日 22:13 UTC](https://meta.discourse.org/t/fakebook-theme/109079/86 "2020-11-24T22:13:17Z")

</div>

> [@hyd504](#):
>
> 有没有办法将 hbr 文件包含到 html 文件中，这样我们就可以直接将 topic-list-item.hbr 包含到 common/header.html 中，而无需在两个地方重复代码？

我不这么认为……通常我可以创建一个使用单一模板的组件，然后在两个覆盖中都包含该组件……但我们的主题列表项是一种专为性能设计的特殊模板类型（hbr = handlebars 原始模板），而原始模板无法使用组件。（此前在 [Mounting widget in raw template? - #7 by angus](https://meta.discourse.org/t/mounting-widget-in-raw-template/44400/7?u=awesomerobot) 中有相关讨论）

> [@hyd504](#):
>
> 为什么我们一开始就需要 topic-list-item.hbr？common 文件夹中的文件不应该同时适用于桌面端和移动端吗？

Discourse 的 CSS 结构正是如此（某些特殊 HTML 文件如页眉/页脚等也遵循此结构），但在 `javascripts/discourse/templates` 目录中，这些模板是对 Discourse 默认模板的直接覆盖（如果没有覆盖，则使用默认模板）。

在 Discourse 中有两个模板：`/templates/list/topic-list-item.hbr` 和 `/templates/mobile/list/topic-list-item.hbr`。因此，既然有两个模板，我们就需要两个覆盖。

也许在 JS 中有一种简单的方法可以将移动端指向非移动端模板……但如果有的话，我目前并不了解！

---

_[View the full topic](https://meta.discourse.org/t/fakebook-theme/109079)._
