当我粘贴代码时,小部件会显示在网站的主页上。我该如何让它显示在网站的某个类别/页面上,而不是主页上?
如果我将代码放在 head 中,它会显示在主页的顶部。body 会让它显示在主页的底部。我该如何让小部件显示在另一个远离主页的页面上?谢谢。
david
(David Taylor)
2025 年5 月 12 日 09:25
5
您好 @Issa_George 。我建议您学习这里的教程,以熟悉主题开发所需的概念和技术。它涵盖了如何在 UI 的各个位置呈现内容:
This tutorial will teach you how to create a Discourse Theme or Theme Component from the ground up. While this topic assumes no previous experience working on Discourse themes, it does assume some prior experience using HTML , CSS and JavaScript . It’ll also help if you know your way around GitHub .
What are Discourse themes?
A theme or theme component is a set of files packaged together designed to either modify Discourse visually or to add new features.
Themes
In general, themes are not suppo…
pfaffman
(Jay Pfaffman)
2025 年5 月 12 日 10:37
6
使用 discourse_theme cli,您会发现主题开发变得更加容易。
正如 David 所说,你应该遵循该教程来学习如何构建一个可以在多个地方渲染的组件,特别是插件插槽,这些插槽分布在网站各处,为渲染组件提供位置。
你可以将代码放在“JS”选项卡中,并将其与 api.renderInOutlet() 和 \u003ctemplate\u003e 标签配对。
嗨 Nate,我在这方面仍然遇到困难。我只是想将 HTML 小部件代码放在类别部分而不是主页面中。我阅读了指南,但它没有清楚地告诉我应该使用什么。我安装了 CLI,但我放在那里的代码在我的网站上不起作用。然后我去了主题创建者网站,我的代码没有显示在预览中。指南中的示例代码有效,当我放入代码时可以看到颜色变化。
pfaffman
(Jay Pfaffman)
2025 年5 月 14 日 11:20
12
您应该使用插件出口和 Glimmer 组件。请参阅有关主题开发的最新指南。
或者,将脚本标签放在 \u003chead\u003e 选项卡中,并将其他代码片段放在 JS 选项卡中(并在其中导入助手)。