repomaa/statamic-unaugment

There is no license information available for the latest version (v1.0.0) of this package.

Statamic addon to disable augmentation for user-defined fields or field types

v1.0.0 2021-03-11 00:40 UTC

This package is auto-updated.

Last update: 2025-06-11 21:29:25 UTC


README

Statamic "augments" field values by default when it serializes them in content api responses. Unaugment lets you define specific fields or field types that will be left alone and return the data without any modifications. This is especially useful for the Bard or Markdown field types which are otherwise rendered into html. By using the unaugmented data you mitigate any chance of XSS in your client application and are free to structure the dom - or your native app's components - however you want.

Configuration

Unaugment will place a sample config file into config. Edit it to define the fields and/or field types you want to unaugment.

Output

Unaugmented Bard field content looks like this:

{
  "data": {
    // ...
    "bard": [
      {
        "content": [
          {
            "text": "Foobar Foo",
            "type": "text"
          },
          {
            "type": "hard_break"
          },
          {
            "type": "hard_break"
          },
          {
            "marks": [
              {
                "type": "bold"
              }
            ],
            "text": "Bold stuff!",
            "type": "text"
          }
        ],
        "type": "paragraph"
      },
      {
        "attrs": {
          "level": 2
        },
        "content": [
          {
            "text": "Header!",
            "type": "text"
          }
        ],
        "type": "heading"
      },
      {
        "content": [
          {
            "marks": [
              {
                "type": "italic"
              }
            ],
            "text": "Cursive",
            "type": "text"
          }
        ],
        "type": "paragraph"
      }
    ]
    // ...
  }
}

Copyright

2021 - Joakim Repomaa