DrupalX AI

DrupalX AI Module Documentation

Introduction

DrupalX was created to empower developers to build bigger, better, and more ambitious Drupal applications by leveraging the latest frontend stack and adding tools to make work faster. The DrupalX AI module adds a Drush command that tackles one of the more difficult aspects of decoupled site development: mapping Drupal content to a component.

DrupalX uses a composable approach to page-building and utilizes paragraphs to achieve this approach, serving both content authors and developers. The idea is that developers can build their React components either by hand or using AI tools like v0.dev, and then leverage AI to build the content modeling, sample data, and the "glue" that connects Drupal content to the component you wish to expose to content authors.

Configuration

To set up the DrupalX AI module, follow these steps:

  1. Navigate to the DrupalX AI settings page: /admin/config/drupalx_ai/settings

  2. Enter your Anthropic API key in the provided field

  3. Save the configuration

Usage

Importing a Paragraph Type from a Next.js Component

Use the following Drush command to start the import process:

drush drupalx-ai:import-from-component

The command will guide you through the following steps:

  1. Select a Next.js component from the ../nextjs/components/ directory

  2. Choose a specific file from the selected component directory

  3. Review the AI-generated paragraph type structure

  4. Confirm the import

Notes

  • Ensure your Next.js components are located in the ../nextjs/components/ directory relative to your Drupal installation

  • The module will only consider .tsx files that are not story files (i.e., not ending with .stories.tsx)

  • The generated paragraph type names will not include the word "paragraph"

  • Field names will only use lowercase alphanumeric characters and underscores, with the first character being a lowercase letter or underscore

Troubleshooting

  • If you encounter API-related errors, ensure your Anthropic API key is correctly set in the module configuration

  • Check the Drupal logs for detailed error messages and debugging information

Additional Resources & Documentation

For more information and the latest updates, visit the DrupalX AI GitHub repository.

Last updated