diff --git a/src/Service/Indexer/IndexSchema2xDocument.php b/src/Service/Indexer/IndexSchema2xDocument.php index df81983..fda15a3 100644 --- a/src/Service/Indexer/IndexSchema2xDocument.php +++ b/src/Service/Indexer/IndexSchema2xDocument.php @@ -25,6 +25,7 @@ class IndexSchema2xDocument extends Document implements IndexDocument public ?string $sp_name = null; public ?string $sp_anchor = null; public ?string $title = null; + public ?string $sp_startletter = null; public ?string $description = null; public ?string $sp_objecttype = null; public ?bool $sp_canonical = null; diff --git a/src/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricher.php b/src/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricher.php index cd6b9d3..a4a0cdf 100644 --- a/src/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricher.php +++ b/src/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricher.php @@ -123,8 +123,8 @@ public function enrichDocument( $doc->sp_archive = $base->getBool('archive'); - $headline = $metadata->getString('headline') - ?: $base->getString('teaser.headline') + $headline = $base->getString('teaser.headline') + ?: $metadata->getString('headline') ?: $base->getString('title'); $doc->sp_title = $headline; @@ -133,6 +133,8 @@ public function enrichDocument( ?: $base->getString('title'); $doc->sp_sortvalue = $sortHeadline; + $doc->sp_startletter = $base->getString('startletter'); + /** @var string[] $keyword */ $keyword = $metadata->getArray('keywords'); $doc->keywords = $keyword; diff --git a/test/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricherTest.php b/test/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricherTest.php index fd8d7b5..f21e574 100644 --- a/test/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricherTest.php +++ b/test/Service/Indexer/SiteKit/DefaultSchema2xDocumentEnricherTest.php @@ -728,6 +728,18 @@ public function testEnrichContactPointContent(): void ); } + public function testEnrichStartletter(): void + { + $doc = $this->enrichWithData(['base' => [ + 'startletter' => 'z', + ]]); + $this->assertEquals( + 'z', + $doc->sp_startletter, + 'unexpected base.startletter', + ); + } + private function enrichWithResource( Resource $resource, ): IndexSchema2xDocument {