# 在规范中添加主题依赖项

**URL:** https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816
**Category:** Feature
**Created:** [2018年二月28日 19:19 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816 "2018-02-28T19:19:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2018年二月28日 19:19 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/1 "2018-02-28T19:19:19Z")

</div>

> As a Discourse theme author, I want to be able to specify child/component themes that are required for my theme to work correctly, so the user (Discourse site admin) doesn’t have to manually go out and add/configure it.

We are working on a downstream theme to work alongside the Mozilla theme (thanks @LeoMcA!) but it’d be nice if we didn’t have to manually specify import their theme and manually link them. Could such a relationship be added to the **about.json** file?

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [2018年二月28日 19:29 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/2 "2018-02-28T19:29:09Z")

</div>

An aside, this would also benefit developers who build themes for clients. It’s becoming a more appealing setup to use a public theme and then tweak it for the client site. But more and more often, they want their customized theme in GitHub for pulling updates and allowing multiple people to work on them. It’d be great to embed the dependency somehow.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2018年二月28日 19:59 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/3 "2018-02-28T19:59:04Z")

</div>

Asking for advanced features like this makes me 😊, means the system is being used

Not against building this but needs very careful testing

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [2018年二月28日 20:17 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/4 "2018-02-28T20:17:16Z")

</div>

I imagine it’d also be useful for you to be able to specify a particular version/commit that the theme depends on - that way, if we completely change something you’re depending on, it won’t all suddenly break on your end.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2018年二月28日 20:27 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/5 "2018-02-28T20:27:18Z")

</div>

> [@LeoMcA](#):
>
> if we completely change something you’re depending on, it won’t all suddenly break on your end

Yes, good point … although makes it a bit more complex. 🙂

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [2018年二月28日 20:35 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/6 "2018-02-28T20:35:35Z")

</div>

> [@downey](#):
>
> Yes, good point … although makes it a bit more complex. 🙂

Maybe. If you can add the dependency as a GitHub link of sorts that allows a specific commit, branch, or tag, it gets easier. But that doesn’t mean the whole feature is easy.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2018年三月1日 00:25 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/7 "2018-03-01T00:25:16Z")

</div>

> [@joebuhlig](#):
>
> GitHub link of sorts

Or any non-GH Git repository 😉

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年三月9日 06:11 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/8 "2020-03-09T06:11:10Z")

</div>

@vinothkannans 刚刚添加了对依赖主题组件初始列表的支持，这样安装捆绑包会容易得多。

他将在此发布更多详情！

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2020年三月9日 10:50 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/9 "2020-03-09T10:50:28Z")

</div>

现在，顶级主题可以在 `about.json` 文件中指定子主题组件列表。例如：

```plaintext
{
  "name": "Material Design Theme",
  "about_url": "https://meta.discourse.org/t/material-design-stock-theme/47142",
  "license_url": "https://github.com/discourse/material-design-stock-theme/blob/master/LICENSE.txt",
  "components": ["https://github.com/discourse/discourse-brand-header", "https://github.com/Chaboi45/Take-a-break-component"]
  .
  .
  .
}

```

目前存在以下限制：

1. 所有子主题组件仅在首次安装时安装。
2. 如果之后在 `about.json` 中移除了组件，已安装的子主题组件不会被卸载。
3. 如果手动删除了已安装的主题组件，系统将不会重新安装它。
4. 无法为另一个主题组件指定子主题组件。

---

<div class="post-metadata">

### Author: ![traceymoko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/traceymoko/32/483235_2.png) [@traceymoko](https://meta.discourse.org/u/traceymoko)
#### Post date: [2021年三月29日 11:14 UTC](https://meta.discourse.org/t/add-theme-dependencies-in-specification/81816/10 "2021-03-29T11:14:19Z")

</div>

我在想，是否可以考虑允许为捆绑的主题组件设置默认配置。

例如，修改 [Discourse Button Styles](https://meta.discourse.org/t/discourse-button-styles/88154) 中 [settings.yml](https://github.com/awesomerobot/discourse-button-styles/blob/master/settings.yml) 的默认值，使其匹配顶级主题的具体数值。

 ![37%20AM](https://global.discourse-cdn.com/meta/original/3X/2/5/25955501d91ca84d2c9f925e640b49eb1b7d8641.png)

（目前我认为您可能需要分叉该主题组件才能实现这一点。）
