Overriding a plugin

A plugin is a plain object, so adapting one is a spread: keep its type (stored documents refer to it) and replace what your site does differently — usually the preview, sometimes the fields. An app with its own renderer can also leave preview out altogether.


A map with a caption

The bundled map's editor view, plus a caption field and the site's own preview.

import type { BlockPlugin } from '@atom-forge/brickee';
import { map } from '@atom-forge/brickee/plugins';
import SiteMap from './SiteMap.svelte';

/** The bundled map with an extra field and the site's own preview. Same `type`, so stored maps keep working. */
export const siteMap: BlockPlugin = {
	...map,
	props: () => ({ ...map.props(), caption: '' }),
	fields: [...(map.fields ?? []), { key: 'caption', label: 'Caption', kind: 'text' }],
	tag: (p) => (p.caption ? `map · ${p.caption}` : map.tag(p as never)),
	preview: SiteMap
};
Meet us at the main entrance.