diff --git a/docs/docs/api/overview.md b/docs/docs/api/overview.md new file mode 100644 index 0000000..563cac2 --- /dev/null +++ b/docs/docs/api/overview.md @@ -0,0 +1,354 @@ +--- +sidebar_position: 1 +--- + +# API Reference + +Complete TypeScript API reference for `remark-notes-plugin`. + +## Plugin Function + +### `remarkNotes(options?)` + +The main plugin function that transforms markdown blockquotes into styled note elements. + +**Type Signature:** + +```typescript +function remarkNotes(options?: RemarkNotesOptions): (tree: Node) => void +``` + +**Parameters:** + +- `options` (optional): Configuration object of type `RemarkNotesOptions` + +**Returns:** + +A transformer function that processes the AST (Abstract Syntax Tree). + +**Example:** + +```typescript +import { unified } from 'unified'; +import remarkParse from 'remark-parse'; +import remarkNotes from 'remark-notes-plugin'; +import remarkRehype from 'remark-rehype'; +import rehypeStringify from 'rehype-stringify'; + +const processor = unified() + .use(remarkParse) + .use(remarkNotes, { classPrefix: 'custom' }) + .use(remarkRehype) + .use(rehypeStringify); + +const result = await processor.process('> [!note]\n> This is a note'); +``` + +## Configuration Options + +### `RemarkNotesOptions` + +Configuration interface for the plugin. + +```typescript +interface RemarkNotesOptions { + classPrefix?: string; + injectStyles?: boolean; +} +``` + +#### `classPrefix` + +Custom prefix for all generated CSS class names. + +- **Type:** `string` +- **Default:** `''` (empty string - no prefix) +- **Optional:** Yes + +The prefix is **prepended** to the standard `remark-note` class names. + +**Default behavior (no prefix):** +```html +
++``` + +**With prefix (e.g., `'my'`):** +```html ++ + tip ++...+
++``` + +**Example:** + +```typescript +unified().use(remarkNotes, { classPrefix: 'docs' }); +// Generates: docs-remark-note, docs-remark-note-tip, etc. +``` + +> [!note] +> The shipped CSS uses attribute selectors (e.g., `[class*="remark-note-icon"]`) and will work automatically with any prefix. + +#### `injectStyles` + +Controls whether the plugin automatically injects styles into the document. + +- **Type:** `boolean` +- **Default:** `true` +- **Optional:** Yes + +When `true`, the plugin injects a `+ + tip ++...+