1.0.3 • Published 11 months ago

@aquasite_pl/directus-extension-clean-html v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Directus Clean HTML Extension

A Directus extension that provides an operation to clean and sanitize HTML content in Directus Flows. This extension allows you to selectively remove elements, clean attributes, and optimize HTML structure for further processing (for example to use with AI generation nodes). Compatible with Webhook / Request URL node (use {{$last.data}} as HTML input in this node).

Features

  • Extract specific parts of HTML using CSS selectors
  • Remove unwanted elements using CSS selectors
  • Strip all HTML attributes
  • Remove empty tags recursively
  • Remove HTML comments
  • Process HTML safely using Cheerio

Installation

Use marketplace to install the extension.

Usage

This extension adds a new "Clean HTML" operation that can be used in Directus Flows, particularly with the Webhook or Request URL nodes.

Flow Configuration

  1. Add a Webhook or Request URL node to receive HTML content
  2. Add the Clean HTML operation
  3. Configure the operation options:
{
  "operation": "clean-html",
  "options": {
    "html": "{{$trigger.body.content}}", 
    "workOnSelector": ".content",
    "selectors": ".ads, .comments",
    "cleanAttributes": true,
    "removeEmptyTags": true,
    "removeComments": true
  }
}

Operation Options

OptionTypeDescriptionDefault
htmlstringThe HTML content to processRequired
workOnSelectorstringCSS selector to extract specific HTML portionOptional
selectorsstringComma-separated list of CSS selectors to removeOptional
cleanAttributesbooleanRemove all attributes from elementsfalse
removeEmptyTagsbooleanRemove elements with no contentfalse
removeCommentsbooleanRemove HTML commentsfalse

Response

The operation returns an object:

Requirements

  • Directus version ^10.10.0
  • Node.js

License

MIT License

Author

Paweł Kania

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago