Slot plugins
Slot plugins provide the components that render prepared content such as code, links and headings. Use them to change appearance and interactions.
Declare and use
This example hides the code toolbar while retaining highlighting and code styles. Start with an ordinary Svelte component:
Export the component from its directory entry, then register it for the CodeBlock slot:
key identifies the plugin, type selects the slot, and Component points to the Svelte component. Fluxdown manages plugin creation and cleanup.
Import plugin bases and prop types from
@fluxdown/svelte-plugins/base. Install@fluxdown/svelte-pluginsfirst.
Preserve default behavior
Raw is the rendering snippet supplied by the previous plugin. Call {@render Raw(props)} to preserve existing highlighting or layout, and change its props to adjust one part.
At equal priority, later plugins for the same slot wrap earlier components through Raw. To replace the slot entirely, write your own Svelte template. Slots with nested content render it with {@render children?.()}.
Rawcan benull; check it before rendering. BothRawandchildrenare Svelte snippets.
Add an interaction
For example, track a link click while preserving its previous callback:
Assign TrackedLink to the Component field of a BaseSlotPlugin<'Link'> subclass, then add it to plugins.slots. Your application supplies trackLink.