• English
  • Using and writing plugins

    Plugins follow the content pipeline. Start with slot plugins to change components and interactions; use render plugins to choose a slot for a node. Core plugins handle parsing, repair and streaming transforms.

    TypePurposeGuide
    slotRender a slot with components and interactions.Slot plugins
    renderRender HAST nodes through slots.Render plugins
    mapperReactively transform HAST to reveal content.Mapper plugins
    remarkParse Markdown syntax.Remark plugins
    rehypePost-process HAST.Rehype plugins
    repairPost-process and repair the Markdown AST.Repair plugins

    Add a capability

    Install the plugin package:

    pnpm add @fluxdown/solid-plugins

    For example, add Shiki code highlighting to Lite:

    import { FluxdownLite } from '@fluxdown/solid/lite';
    import { CodeShikiPlugin } from '@fluxdown/solid-plugins/plugins/code-shiki';
    
    type MessageProps = {
      text: string;
    };
    
    export function Message(props: MessageProps) {
      return <FluxdownLite text={props.text} plugins={CodeShikiPlugin} />;
    }

    Import plugins from @fluxdown/solid-plugins/plugins/<plugin-directory>. Directories use lowercase kebab case. See the plugin matrix for the complete list.

    Compose and configure

    plugins accepts one aggregate plugin or an array. Each object can combine slots, renders, remarks, rehypes, repairs and mappers. Its config configures the plugins listed in that object.

    Import IPluginItem from @fluxdown/solid-plugins/typings.

    Full and Lite apply your plugins after their presets. Raw uses the supplied rendering plugins while retaining Core's Markdown pipeline. At the same priority, later render plugins match first, and later slot plugins wrap the earlier component through Raw.

    See aggregate plugins for declaration and extension examples. You can also pass a mapper directly to streaming.effect; see configuration.