From 6d97f331fdd5f3248f1a850a430924c110bd2edd Mon Sep 17 00:00:00 2001 From: Tim Wagner <tim.wagner@sgalinski.de> Date: Tue, 5 Feb 2019 12:03:05 -0330 Subject: [PATCH] [TASK] Add JSON-LD for sg_news overview page list of latest news --- .../TypoScript/Partials/SgNewsSchema/Setup.ts | 115 ------------------ .../Templates/ListByCategory/Index.html | 35 ++++++ .../Overview/OverviewWithoutCategories.html | 2 +- 3 files changed, 36 insertions(+), 116 deletions(-) delete mode 100644 Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts diff --git a/Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts b/Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts deleted file mode 100644 index 0b414c7..0000000 --- a/Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts +++ /dev/null @@ -1,115 +0,0 @@ -#[page["author"] && {$plugin.tx_sgnews.settings.publisher} && {$plugin.tx_sgnews.settings.publisherLogo}] - -# @todo See if this can replace the stuff from "SingleView.html" - -lib.sgNews.sg_news_schema = COA -lib.sgNews.sg_news_schema { - 10 = TEXT - 10 { - typolink.parameter.field = uid - typolink.forceAbsoluteUrl = 1 - typolink.returnLast = url - htmlSpecialChars = 1 - wrap = "mainEntityOfPage": { "@type": "WebPage", "@id": "|" }, - } - - 20 = TEXT - 20 { - field = subtitle - stdWrap.replacement.10 { - search = " - replace = \" - } - - wrap = "headline": "|", - } - - 30 = FILES - 30 { - references { - table = pages - uid.data = page:uid - fieldName = tx_sgnews_teaser1_image - } - - renderObj = TEXT - renderObj { - typolink { - parameter.stdWrap { - cObject = IMG_RESOURCE - cObject { - file.import.data = file:current:uid - file.treatIdAsReference = 1 - } - } - - returnLast = url - forceAbsoluteUrl = 1 - } - - wrap = "image": [ "|" ], - } - } - - 40 = TEXT - 40 { - value { - field = crdate - strftime = %c - wrap = "datePublished": "|", - } - } - - 50 = TEXT - 50 { - value { - field = lastUpdated - strftime = %c - wrap = "dateModified": "|", - } - } - - 60 = TEXT - 60 { - field = author - wrap = "author": { "@type": "Person", "name": "|" }, - } - - 70 = COA - 70 { - # @todo only implement if both values are set! - 701 = TEXT - 701 { - value = {$plugin.tx_sgnews.settings.publisher} - wrap = "publisher": { "@type": "Organization", "name": "|", - } - - 702 = TEXT - 702 { - value = {$plugin.tx_sgnews.settings.publisherLogo} - wrap = "logo": { "@type": "ImageObject", "url": "|" }}, - } - } - - - 80 = TEXT - 80 { - field = description - stdWrap.replacement.10 { - search = " - replace = \" - } - - wrap = "description": "|" - } - - /* - Things one could implement: - - "comment" tag for comments - - "commentCount" - - "thumbnailUrl" - - "translationOfWork" for additional language versions - */ -} - -# [GLOBAL] diff --git a/Resources/Private/Templates/ListByCategory/Index.html b/Resources/Private/Templates/ListByCategory/Index.html index 33a786b..cb87a07 100644 --- a/Resources/Private/Templates/ListByCategory/Index.html +++ b/Resources/Private/Templates/ListByCategory/Index.html @@ -3,6 +3,41 @@ {namespace sg=SGalinski\SgNews\ViewHelpers} <f:section name="main"> + <f:alias map="{leftBrace: '{', rightBrace: '}'}"> + <script type="application/ld+json"> + {leftBrace} + "@context": "http://schema.org/", + "@type": "ItemList", + "itemListElement": [ + <f:for each="{newsMetaData}" as="newsMetaDataEntry" iteration="iterator"> + {leftBrace} + "@type": "Article", + "author": "{newsMetaDataEntry.news.author}", + "mainEntityOfPage": "<f:uri.page pageUid="{newsMetaDataEntry.news.uid}" absolute="TRUE"/>", + "publisher": {leftBrace} + "@type": "Organization", + "name": "{settings.publisher}", + "logo": {leftBrace} + "@type": "ImageObject", + "url": "{settings.publisherLogo}" + {rightBrace} + {rightBrace}, + "image": "<f:uri.image absolute="TRUE" image="{newsMetaDataEntry.imageObject}" />", + "headline": "{newsMetaDataEntry.news.navTitle}", + "description": "{newsMetaDataEntry.news.description}", + "dateCreated": "<f:format.date format="Y-m-d">{newsMetaDataEntry.news.creationDate}</f:format.date>", + "datePublished": "<f:format.date format="Y-m-d">{newsMetaDataEntry.news.creationDate}</f:format.date>", + "dateModified": "<f:format.date format="Y-m-d">{newsMetaDataEntry.news.lastUpdated}</f:format.date>", + "position": "{iterator.cycle}", + "url": "<f:uri.page pageUid="{newsMetaDataEntry.news.uid}" absolute="TRUE"/>" + {rightBrace}<f:if condition="{iterator.isLast} == FALSE">,</f:if> + </f:for> + ], + "numberOfItems": "{newsMetaData->f:count()}" + {rightBrace} + </script> + </f:alias> + <section class="content light-bg"> <div class="container"> <f:for each="{categories}" as="category"> diff --git a/Resources/Private/Templates/Overview/OverviewWithoutCategories.html b/Resources/Private/Templates/Overview/OverviewWithoutCategories.html index b198d9a..3a2c5e5 100644 --- a/Resources/Private/Templates/Overview/OverviewWithoutCategories.html +++ b/Resources/Private/Templates/Overview/OverviewWithoutCategories.html @@ -34,4 +34,4 @@ </f:if> </div> <sg:pageBrowser numberOfPages="{numberOfPages}" /> -</f:section> \ No newline at end of file +</f:section> -- GitLab