API Overview
The addon exports the following from its main entry point:
ts
import {
definePattern,
renderTwig,
initTwig,
colorArgType,
CONTEXT_COLORS,
} from '@pdrittenhouse/storybook-addon-twig-wordpress';
import type {
AddonOptions,
WordPressContextMock,
ContextColor,
} from '@pdrittenhouse/storybook-addon-twig-wordpress';Exports
| Export | Kind | Description |
|---|---|---|
definePattern | function | Creates render + args fields for a Storybook Meta object |
renderTwig | function | Renders a registered template with args — used internally by definePattern |
initTwig | function | Registers templates and applies shims — called once by preview.ts |
colorArgType | function | Returns a Storybook argType config for contextual color fields |
CONTEXT_COLORS | const | Readonly array of default contextual color names |
AddonOptions | interface | Options object for the addon's main.ts config |
WordPressContextMock | interface | Shape of the WP context mock injected into every story |
ContextColor | type | Union type of all default contextual color string literals |
Preset exports
The addon also exports Storybook preset hooks from @pdrittenhouse/storybook-addon-twig-wordpress/preset:
| Export | Description |
|---|---|
viteFinal | Merges namespace aliases, SCSS additionalData, and the twig-registry Vite plugin into the Vite config |
webpackFinal | Same for webpack — adds raw-loader for .twig files and namespace aliases |
previewAnnotations | Registers preview.ts as a global decorator entry |
These are consumed automatically by Storybook when the addon is listed in addons — you do not need to call them directly.