mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
Adds plugin API:
```js
import fidget from "../components/styleguide/molecules/fidget";
api.addStyleguideSection({
component: fidget,
id: "fidget",
category: "molecules",
priority: 0,
});
```
Removes notes. You can always add `<p class="styleguide-note">` to section components to annotate them.
43 lines
1015 B
JavaScript
43 lines
1015 B
JavaScript
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
import { addSection } from "../lib/styleguide";
|
|
|
|
/**
|
|
* Add a section to the styleguide
|
|
*
|
|
* @function addStyleguideSection
|
|
* @param {Object} section
|
|
* @param {Component} section.component
|
|
* @param {string} options.id
|
|
* @param {string} options.category
|
|
* @param {number} [options.priority]
|
|
* @example
|
|
*
|
|
* import fidget from "../components/styleguide/molecules/fidget";
|
|
*
|
|
* api.addStyleguideSection({
|
|
* component: fidget,
|
|
* id: "fidget",
|
|
* category: "molecules",
|
|
* priority: 0,
|
|
* });
|
|
*/
|
|
|
|
export default {
|
|
name: "styleguide-plugin-api",
|
|
before: "inject-discourse-objects",
|
|
|
|
initialize() {
|
|
withPluginApi("1.2.0", (api) => {
|
|
const apiPrototype = Object.getPrototypeOf(api);
|
|
|
|
if (!apiPrototype.hasOwnProperty("addStyleguideSection")) {
|
|
Object.defineProperty(apiPrototype, "addStyleguideSection", {
|
|
value(section) {
|
|
addSection(section);
|
|
},
|
|
});
|
|
}
|
|
});
|
|
},
|
|
};
|