你好,
有人能帮我将活动主题的 ID 添加为 <html> 或 <body> 的 CSS 类吗?
我需要编写一些样式,并且某些主题需要不同的属性。
例如,当使用“dark-theme”时:
<html class="desktop-view not-mobile-device text-size-normal dark-theme">
你好,
有人能帮我将活动主题的 ID 添加为 <html> 或 <body> 的 CSS 类吗?
我需要编写一些样式,并且某些主题需要不同的属性。
例如,当使用“dark-theme”时:
<html class="desktop-view not-mobile-device text-size-normal dark-theme">
我们不使用名称作为 ID,只使用数字。你可以在管理员面板中自定义主题时查看 URL 来获取主题的 ID,例如 https://forum.example.com/admin/customize/themes/140。
如果你可以使用 ID 而无需名称,这是一种快速实现方法(将其添加到你的主题/组件的 head 文件中):
<script type="text/discourse-plugin" version="0.8">
var themeSelector = require('discourse/lib/theme-selector');
document.querySelector("body").classList.add("theme-id-" + themeSelector.currentThemeId())
</script>
你也可以通过 ID 查找主题名称,但这需要更多的工作。
谢谢,Kris,@awesomerobot
有没有关于 Discourse 插件及相关库方法的文档?
我找到了这个,但它似乎没有包含所有库和方法:
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.