You are here

protected function AmpPrepareMetadataJson::prepareHeadline in Accelerated Mobile Pages (AMP) 8

Prepare headline of content, if available: maximum 110 characters.

1 call to AmpPrepareMetadataJson::prepareHeadline()
AmpPrepareMetadataJson::prepareMetadataJson in src/Utility/AmpPrepareMetadataJson.php
Prepares a metadata array to be ready for JSON conversion.

File

src/Utility/AmpPrepareMetadataJson.php, line 172

Class

AmpPrepareMetadataJson
Class AmpPrepareMetadataJson

Namespace

Drupal\amp\Utility

Code

protected function prepareHeadline() {
  if (isset($this->ampMetadataSettings['content_headline_token']) && !empty($this->ampMetadataSettings['content_headline_token'])) {
    $headline = PlainTextOutput::renderFromHtml($this->token
      ->replace($this->ampMetadataSettings['content_headline_token'], [
      'node' => $this->node,
    ]));
    $this->ampPreparedMetadataJson['headline'] = strlen($headline) > 110 ? mb_strimwidth($headline, 0, 107, "...") : $headline;
  }
}