Meta data (OpenGraph) toegevoegd.

This commit is contained in:
2020-02-05 00:40:55 +01:00
parent dc10050e40
commit 1b7527cccf
4 changed files with 62 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ namespace Model;
require_once "NewsImage.php";
require_once "NewsSource.php";
require_once "MetaData.php";
class NewsItem extends Model {
public $id;
@@ -24,6 +25,7 @@ class NewsItem extends Model {
public $video;
public $url;
public $metadata;
public function __construct($data, $images = null, $podcast = null) {
parent::__construct($data);
@@ -88,6 +90,15 @@ class NewsItem extends Model {
}
$this->url = "/nieuws/{$this->id}/" . parent::url_slug($this->title);
$this->metadata = (new MetaData())
->set('title', $this->title)
->set('description', strip_tags($this->excerpt()))
->set('image', isset($this->images) && count($this->images) ? $this->images[0]->url : null )
->set('video', isset($this->video) ? $this->video : null)
->set('audio', isset($this->podcast) ? $this->podcast->url : null)
->set('article:published_time', $this->published->format('r'))
->set('article:modified_time', $this->edited ? $this->edited->format('r') : null)
;
}
public function excerpt() {