sdc_entity_mapping
SDC Entity Mapping lets site builders map Drupal entity data to Single-Directory Component (SDC) props using reusable mapping profiles. This makes it possible to render the same component from entity content in a consistent way without making the component itself depend on Drupal entities.
Features
This module provides a reusable mapping layer between Drupal entities and SDC props. A mapping profile can define how values such as title, summary, URLs, images, and static text should be resolved and passed into a component.
- Creates reusable config entities for mapping Drupal entity data to SDC props.
- Keeps SDCs stateless by resolving Drupal data before rendering.
- Supports static values and entity-path-based values.
- Supports simple transforms such as plain text, summary extraction, entity URLs, and image URLs.
- Includes optional submodules for demonstration and for block-based placement.
This project is useful when you want a Single-Directory Component to display Drupal content, but you do not want the component schema itself to become Drupal-aware. It is especially useful when the same component should be reused with different entities or in different placement systems.
Examples include:
- Rendering a card component from an Article or Basic Page.
- Creating reusable mapping profiles that can later be used by blocks or other integrations.
- Laying groundwork for future integrations such as entity reference field formatters or Canvas-specific authoring UX.
Post-Installation
After enabling the base module, go to the mapping administration page and create one or more mapping profiles. Each mapping profile targets an SDC and defines how entity values should be resolved into that component’s props.
If you also enable the optional Block submodule, you can place a generic mapped-component block and choose:
- which saved mapping to use
- whether the source entity should come from the current route or a fixed entity ID
If you enable the optional Demo submodule, it provides sample components and sample mappings so you can inspect a working example.
Recommended setup flow:
- Enable
sdc_entity_mapping. - Create or review one or more SDCs with defined props.
- Create a mapping profile at the module’s configuration page.
- Optionally enable
sdc_entity_mapping_blockto place mapped components as blocks. - Optionally enable
sdc_entity_mapping_demoto explore example components and mappings.
Additional Requirements
No external libraries are required.
This project is intended for sites using Drupal core Single-Directory Components. Single-Directory Components are included in Drupal core in modern Drupal versions.
Recommended modules/libraries
Optional companion submodules included in this project:
sdc_entity_mapping_block: provides a generic mapped-component block placement option.sdc_entity_mapping_demo: provides sample SDCs and sample mappings.
Depending on site needs, a future ecosystem module could integrate these mappings with other authoring systems such as Paragraphs or other page-building workflows.
Canvas provides a browser-based site-building and composition experience. This project complements Canvas by supplying reusable entity-to-SDC mappings that can already be used through block placement today (requires sdc_entity_mapping_block), while leaving room for richer Canvas-specific integrations later.
Similar projects
Single Directory Components: Display (SDC Display) lets site builders use SDCs in Drupal’s Manage Display UI, including mapping components to fields and view modes. This project is different: it focuses on reusable mapping profiles that resolve entity data into SDC props outside the Manage Display pipeline. That makes it a better fit for generic consumers such as a mapped-component block today and other integrations later.
Supporting this Module
Issues, testing feedback, and patches are welcome.
Community Documentation
Project documentation should cover:
- creating a mapping profile
- supported source types and transforms
- using the optional block submodule
- guidance for component authors on optional versus required props
Future documentation may also include walkthroughs for entity reference formatter integrations and Canvas-oriented authoring workflows.
Project status: this project is currently a proof of concept intended to explore a Drupal-wide pattern for mapping entity data into stateless SDC props.