CONNECT-platform / codedoc

Create beautiful modern documentation websites.

Home Page:https://codedoc.cc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

best way to share custom components

nakednous opened this issue · comments

Since I finished my p5.js component I was wondering if there's a standard way to share it?

yes, writing a codedoc plugin for easy consumption of the component, and publishing it on NPM. I guess we should also add a page to the docs somewhere for community plugins now, so would appreciate if you would mention the final plugin here as well.

I managed to merge the code of the component with that of the plugin into the p5-plugin, i.e., I just added the plugin export function p5Plugin(): ConfigOverride to the index.tsx component file. It works as expected by:

  1. Copy the p5-plugin dir contents into .codedoc.
  2. Import the plugin into config.ts:
    import { p5Plugin } from './p5-plugin/index';
    export const config = configuration({
     //...
     plugins: [p5Plugin],
    });

Since this is my first node package I have several questions:

  1. Should I use a scoped package? If so, should it go inside @codedoc/ or @connectv/?
  2. Will import { p5Plugin } from './p5-plugin/index'; still be the line to import the plugin into config.ts once the package is created, published and installed? Or how should it be imported?
  3. Is there any naming convention to be followed for the plugins, e.g., p5-codedoc-plugin?
  1. Should I use a scoped package? If so, should it go inside @codedoc/ or @connectv/?

no. scoped packages are for organizational packages. since you are the primary maintainer of this package and not @codedoc or @connectv organizations, I suspect a better naming scheme would be codedoc-p5-plugin or something.

  1. Will import { p5Plugin } from './p5-plugin/index'; still be the line to import the plugin into config.ts once the package is created, published and installed? Or how should it be imported?

nope, it will be something like import { p5Plugin } from 'codedoc-p5-plugin';.

p.s. publishing a typescript-based package can have some nuances, so I would also recommend taking a look at this plugin, specifically package.json and conf/typescript folders if you run into issues for proper exports (this is the template that I use for all typescript packages I publish).