An open API service indexing awesome lists of open source software.

https://github.com/daun/statamic-bard-mutators

A collection of mutators for transforming Statamic Bard content
https://github.com/daun/statamic-bard-mutators

bard plugins statamic

Last synced: 4 months ago
JSON representation

A collection of mutators for transforming Statamic Bard content

Awesome Lists containing this project

README

          

# đŸ§±  Statamic Bard Mutators

A collection of mutators for transforming [Statamic Bard](https://statamic.dev/fieldtypes/bard) content.

All mutators are implemented as plugins for the [Bard Mutator Addon](https://statamic.com/addons/jacksleight/bard-mutator).

## Installation

Install the package via composer:

```bash
composer require daun/statamic-bard-mutators
```

## Registration

Register any mutators you want to use from the `Mutator` facade. Options can be passed as arguments
to the constructor. You can read more about
[class-based mutator plugins](https://jacksleight.dev/docs/bard-mutator/plugins#class-based-plugins)
in the addon readme.

```php
use JackSleight\StatamicBardMutator\Facades\Mutator;
use Daun\BardMutators\MarkExternalLinks;

Mutator::plugin(new MarkExternalLinks());
```

## Mutators

### Mark External Links

Mark external links with `target="_blank"` and `rel="external"`.

```html

External link

External link
```

```php
new MarkExternalLinks();

// Optionally customize the `target` and `rel` attributes
new MarkExternalLinks(
target: '_blank',
rel: 'noopener noreferrer'
);
```

### Mark Asset Links

Mark links to assets with `download="filename.ext"`.

```html

Download video

Download video
```

```php
new MarkAssetLinks();
```

### Generate Heading IDs

Adds an `id` attribute to headings based on their content.

```html

Heading

Heading


```

```php
new GenerateHeadingIds();

// Customize heading levels to generate IDs for and add a prefix to generated IDs
new GenerateHeadingIds(
levels: [2, 3],
prefix: 'section-'
);
```

### Semantic Blockquotes

Wraps blockquotes in a `figure` element and moves the author/source into a `figcaption` element.

```html


Quote


— Author



Quote




Author

```

```php
new SemanticBlockquotes();

// Optionally add a class to the figure element
new SemanticBlockquotes(
class: 'quote'
);
```

## Wrap Tables

Wraps tables in a `div` element to allow for horizontal scrolling on smaller screens.

```html

...


...

```

```php
new WrapTables();

// Optionally use a custom tag or add a class to the wrapper element
new WrapTables(
tag: 'section',
class: 'table'
);
```

## Remove List Item Paragraphs

Remove the paragraphs that tiptap automatically adds inside list items.

```html


  • List item



  • List item

  • ```

    ```php
    new RemoveListItemParagraphs();
    ```

    ## License

    [MIT](https://opensource.org/licenses/MIT)