I'd like to add a couple classes to the "Read more" and "Add new comment" links in my article teasers in Drupal 8.
I'd do this in Drupal 7 by doing something like this in my theme file:.
function mytheme_preprocess_node(&$variables) {
$variables['content']['links']['node']['#links']['node-readmore']['attributes']['class'][] = 'btn btn-primary';
$variables['content']['links']['node']['#links']['comment-add']['attributes']['class'][] = 'btn btn-primary';
}
But this doesn't work in Drupal 8. I dumped the contents of $variables['content']['links']
and all I got was this:
$variables['...']['...'] array(2)
'#lazy_builder' => array(2)
string(40) "Drupal\node\NodeViewBuilder::renderLinks"
array(4)
string(1) "4"
string(6) "teaser"
string(2) "en"
boolFALSE
'#weight' => integer100
So how would I go about adding classes to these links in Drupal 8?