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 toextractFieldValue().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— queriesmenu_link_contentstorage 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 frommapping(boolean values per key) tosequenceof strings. Migrated bycontent_first_update_20005().entity_extra_fields— newsequenceof field machine names; default[].include_menu_link— newboolean; defaultfalse.
Issue fork content_first-3594012
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
Comment #4
gedur commented