Problem/Motivation

The entity properties exported under the entity key in the markdown front matter are hardcoded to seven fixed fields: id, type, bundle, status, langcode, created, and changed. Sites may have other base fields worth exporting (e.g. uid, promote, sticky), but there is no way to select them.

Additionally, bundle-specific fields that are not rendered in the full view mode — such as a field_summary used only in teasers — are silently omitted from the export with no option to include them.

Finally, when a node is linked to a menu via menu_link_content, the menu link title and description are useful context for LLMs and documentation tools, but are never exported.

Proposed resolution

Dynamic entity property selection. The entity_properties configuration is changed from a fixed boolean mapping to a sequence of enabled property names (same pattern as allowed_metatags). The config form dynamically discovers all node base fields via EntityFieldManagerInterface::getBaseFieldDefinitions() and lists them as selectable options. The original seven remain pre-selected by default. Internal revision-tracking columns (revision_default, revision_translation_affected, default_langcode) are excluded from the list.

Extra field attributes. A new entity_extra_fields sequence config stores bundle-specific field names to include in front matter. The config form discovers all non-base fields across enabled node bundles and presents them as checkboxes (none selected by default). Enabled fields are exported under a fields: key in the YAML front matter. Entity-reference fields export the referenced entity label; multi-value fields export an array.

Menu link data. A new include_menu_link boolean config (default false) enables querying menu_link_content entities that point to the current node. When a link is found, title, menu_name, and optionally description are exported under a menu: key. Silently skipped when the menu_link_content module is not available.

A content_first_update_20005() hook migrates existing entity_properties mapping config to the new sequence format and initialises the two new settings.

Remaining tasks

  • Review and testing
  • Automated tests covering the new config form options and builder output

User interface changes

The Content First settings form gains two new sections and one new checkbox:

  • Entity properties — now lists all available node base fields dynamically instead of a fixed set.
  • Extra field attributes — new collapsible section listing bundle-specific fields grouped and deduplicated across enabled content types. None selected by default.
  • Include menu link data — new checkbox, unchecked by default.

API changes

ContentFirstBuilder gains three new protected methods:

  • extractPropertyValue(ContentEntityInterface $entity, string $prop): mixed — routes computed properties (id, type, bundle) to entity methods and delegates all other names to extractFieldValue().
  • extractFieldValue(ContentEntityInterface $entity, string $field_name): mixed — generic field reader returning a scalar or array; handles entity references by returning the referenced entity label.
  • extractMenuLinkData(ContentEntityInterface $entity): array — queries menu_link_content storage for a link pointing to the entity and returns the menu link data array.

The hardcoded if blocks in extractAttributes() are replaced by a loop over the sequence config. A backward-compatibility shim handles sites where the old boolean-mapping format is still stored.

Data model changes

content_first.settings config changes:

  • entity_properties — type changed from mapping (boolean values per key) to sequence of strings. Migrated by content_first_update_20005().
  • entity_extra_fields — new sequence of field machine names; default [].
  • include_menu_link — new boolean; default false.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gedur created an issue. See original summary.

  • gedur committed a9ee7eb5 on 2.x
    Issue #3594012: Allow dynamic entity property selection, extra field...
    
gedur’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.