From 2059de7bf95442344c8318b3d2f75cdb7d66acfb Mon Sep 17 00:00:00 2001
From: Tim Wagner <tim.wagner@sgalinski.de>
Date: Thu, 31 Jan 2019 12:06:30 -0330
Subject: [PATCH] [TASK][WIP] Add new SgNewsSchema file that can add metadata
 to header of news pages

---
 .../TypoScript/Partials/SgNewsSchema/Setup.ts | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts

diff --git a/Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts b/Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts
new file mode 100644
index 0000000..25f4340
--- /dev/null
+++ b/Configuration/TypoScript/Partials/SgNewsSchema/Setup.ts
@@ -0,0 +1,99 @@
+# @todo Add conditions
+[globalVar = TSFE:page|author = *]
+	# && [globalVar = {$plugin.tx_sgnews.settings.publisher} > 0] && [globalVar = {$plugin.tx_sgnews.settings.publisherLogo} > 0]
+
+	# @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
+			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
+			wrap = "description": "|"
+		}
+
+	}
+[GLOBAL]
-- 
GitLab