Files
Jarek RadoszandGitHub 849666a323 DEV: Remove renderTemplate from the styleguide (#21660)
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.
2023-05-25 11:22:36 +02:00

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);
},
});
}
});
},
};