DrupalX Decoupled
  • Overview
  • Development
    • Getting Started
      • Installation
      • Setup
    • DrupalX Frontend with Next
    • DrupalX AI
  • Managing Content
    • Building with Paragraphs
  • External Links
    • DrupalX Decoupled Storybook
    • DrupalX Drupal.org
Powered by GitBook
On this page
  • DrupalX Next.js Integration
  • Overview
  • Component Structure
  • Paragraph Integration
  • Landing Pages
  • Best Practices
  • Further Resources
  1. Development

DrupalX Frontend with Next

PreviousSetupNextDrupalX AI

Last updated 8 months ago

DrupalX Next.js Integration

Overview

DrupalX comes with a fully-integrated Next.js frontend, configured to query data from DrupalX using the GraphQL module. This documentation outlines the structure and integration process for developers working with DrupalX and Next.js.

Component Structure

  • All DrupalX components are located in the ./nextjs/components folder.

  • Components are created using Shadcn/ui and organized in Storybook.

  • The components/paragraphs folder contains integration templates for Drupal paragraphs.

Paragraph Integration

The ParagraphUnionFragment in ./nextjs/graphql/fragments/paragraph.ts controls which paragraphs render from landing pages. This setup facilitates easy management of paragraph types in Drupal.

Integrating a New Paragraph Type

To integrate a new paragraph type configured in Drupal:

  1. Add the paragraph type name to components/paragraphs/Paragraph[Bundle].tsx.

  2. In the same file, add fragments and props using the naming convention that includes the paragraph bundle/type.

    • Refer to the GraphQL Compose Fragments module in Drupal for recommended GraphQL fragments.

  3. Update ./nextjs/graphql/fragments/paragraph.ts by adding the new paragraph type to the ParagraphUnionFragment constant.

Landing Pages

The "landing" content type in Drupal is set up to work seamlessly with this paragraph integration system.

Best Practices

  • Maintain consistent naming conventions across Drupal and Next.js components.

  • Regularly review and update the ParagraphUnionFragment to ensure all necessary paragraph types are included.

  • Utilize Storybook for component development and testing.

Further Resources

Shadcn/ui Documentation
Next.js Documentation
Drupal GraphQL Module Documentation
Paragraphs folder with integration templates
ParagraphUnionFragment combines the paragraphs together
Example paragraph component