Plugin Shape
Custom plugins implement OberonPlugin:
export type OberonPlugin = (adapter: OberonPluginAdapter) => {
name: string
version?: string
disabled?: boolean
handlers?: Record<string, (adapter: OberonAdapter) => OberonHandler>
adapter?: Partial<OberonPluginAdapter>
}Input
The plugin function receives the current accumulated OberonPluginAdapter.
That means a plugin can:
- inspect capabilities already provided by earlier plugins
- wrap or replace existing adapter methods
- return handler factories that will later receive the final runtime
OberonAdapter
Return value
name
Required. Used for site config and plugin version reporting.
version
Optional. Included in plugin version metadata.
disabled
Optional. When true, the plugin is recorded in plugin metadata but its
adapter and handlers are not merged.
adapter
Optional. A partial OberonPluginAdapter. Only provide the methods your plugin
owns or overrides.
handlers
Optional. A map of route segment to handler factory. These are merged into the CMS handler tree and dispatched by the first path segment.
Merge behavior
Plugins are initialised left to right by initPlugins.
- returned
handlersare merged into the accumulated handler map - returned
adaptermethods are merged into the accumulated adapter - later keys overwrite earlier keys
- disabled plugins contribute version metadata only
Minimal shape
import type { OberonPlugin } from "@oberoncms/core"
export const plugin: OberonPlugin = () => ({
name: "my-plugin",
})Plugin with adapter and handlers
import type { OberonPlugin } from "@oberoncms/core"
export const plugin: OberonPlugin = () => ({
name: "my-plugin",
adapter: {
signOut: async () => {},
},
handlers: {},
})Use Adapter Hooks for the adapter surface and Handler Hooks for route handlers.
Last updated on