Skip to content

Commit

Permalink
Merge pull request #118 from FriendsOfREDAXO/json-ld
Browse files Browse the repository at this point in the history
Fragmente für JSON+LD-Ausgabe (schema.org)
  • Loading branch information
alxndr-w authored Sep 13, 2024
2 parents 2322383 + 06a7e00 commit a9c0227
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fragments/neues/Article.json-ld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace FriendsOfRedaxo\Neues;

use IntlDateFormatter;

/** @var \rex_fragment $this */
$entry = $this->getVar('entry');
/** @var Entry $entry */
?>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"url": "<?= Neues::htmlEncode($entry->getUrl()); ?>",
"publisher":{
"@type":"Organization",
"name":"<?= Neues::htmlEncode(\rex::getserverName()); ?>",
},
"headline": "<?= Neues::htmlEncode($entry->getName()); ?>",
"mainEntityOfPage": "<?= Neues::htmlEncode($entry->getUrl()); ?>",
"articleBody": "<?= Neues::htmlEncode($entry->getDescriptionAsPlaintext()); ?>",
"image": <?= json_encode(Neues::htmlEncode($entry->getImages())); ?>,
"datePublished": "<?= Neues::htmlEncode((new \DateTime($entry->getPublishDate()))->format(\DateTime::ATOM)); ?>"
}
</script>
26 changes: 26 additions & 0 deletions fragments/neues/NewsArticle.json-ld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace FriendsOfRedaxo\Neues;

use IntlDateFormatter;

/** @var \rex_fragment $this */
$entry = $this->getVar('entry');
/** @var Entry $entry */
?>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "NewsArticle",
"url": "<?= Neues::htmlEncode($entry->getUrl()); ?>",
"publisher":{
"@type":"Organization",
"name":"<?= Neues::htmlEncode(\rex::getserverName()); ?>",
},
"headline": "<?= Neues::htmlEncode($entry->getName()); ?>",
"mainEntityOfPage": "<?= Neues::htmlEncode($entry->getUrl()); ?>",
"articleBody": "<?= Neues::htmlEncode($entry->getDescriptionAsPlaintext()); ?>",
"image": <?= json_encode(Neues::htmlEncode($entry->getImages())); ?>,
"datePublished": "<?= Neues::htmlEncode((new \DateTime($entry->getPublishDate()))->format(\DateTime::ATOM)); ?>"
}
</script>

0 comments on commit a9c0227

Please sign in to comment.