Adding a programmatically defined computed field to an entity in modern Drupal 8 9 10

Ran into an issue where Computed Field module caused infinite loops. Changing the field from multiple (unlimited) value to single value fixed this.

Also, an aside: The fact that Computed Field module does not use proper hooks but rather asks you to create functions with the computed_field namespace in your own module is very un-Drupal and quite ridiculous on the face of it, and really makes me fear for the code quality overall.

Not clear if the output of the ’textfield’ computed field can be a render array.

Proposed using a computed field, since one was already needed for a very unusual situation of producing links to some published and unpublished nodes but only plain text for others, for another situation that was trying to do similar unusual if theoretically less impossible attempts to circumvent Drupal not rendering / providing IDs of referenced unpublished nodes for anonymous viewers. That approach replaces these frightening searches: