Skip to content

Commit 56762f3

Browse files
committed
More OG improvement
1 parent e488a91 commit 56762f3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/Http/Controllers/ShowDocumentationController.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,20 @@ public function __invoke(Request $request, string $platform, string $version, ?s
4646
} catch (InvalidArgumentException $e) {
4747
return $this->redirectToFirstNavigationPage($navigation, $page);
4848
}
49-
SEOTools::setTitle($pageProperties['title'].' - NativePHP '.$platform.' v'.$version);
50-
SEOTools::setDescription(Arr::exists($pageProperties, 'description') ? $pageProperties['description'] : '');
49+
$title = $pageProperties['title'].' - NativePHP '.$platform.' v'.$version;
50+
$description = Arr::exists($pageProperties, 'description') ? $pageProperties['description'] : 'NativePHP documentation for '.$platform.' v'.$version;
51+
52+
SEOTools::setTitle($title);
53+
SEOTools::setDescription($description);
54+
55+
// Set OpenGraph metadata
56+
SEOTools::opengraph()->setTitle($pageProperties['title']);
57+
SEOTools::opengraph()->setDescription($description);
58+
SEOTools::opengraph()->setType('article');
59+
60+
// Set Twitter Card metadata
61+
SEOTools::twitter()->setTitle($pageProperties['title']);
62+
SEOTools::twitter()->setDescription($description);
5163

5264
return view('docs.index')->with($pageProperties);
5365
}

0 commit comments

Comments
 (0)