Add Open Graph tags functionality
This commit is contained in:
parent
6879fad5fb
commit
875408a27c
2 changed files with 27 additions and 0 deletions
|
|
@ -64,6 +64,15 @@ function renderFile(Context $ctx, string $filePath): void {
|
|||
$pageCssUrl = $pageCss['url'] ?? null;
|
||||
$pageCssHash = $pageCss['hash'] ?? null;
|
||||
|
||||
// Check for cover image for social media
|
||||
$coverImage = findCoverImage($pageDir);
|
||||
$socialImageUrl = null;
|
||||
if ($coverImage) {
|
||||
$relativePath = str_replace($ctx->contentDir, '', $pageDir);
|
||||
$relativePath = trim($relativePath, '/');
|
||||
$socialImageUrl = '/' . ($relativePath ? $relativePath . '/' : '') . $coverImage;
|
||||
}
|
||||
|
||||
// Wrap content with page template
|
||||
ob_start();
|
||||
include $ctx->templates->page;
|
||||
|
|
@ -107,6 +116,15 @@ function renderMultipleFiles(Context $ctx, array $filePaths, string $pageDir): v
|
|||
$pageCssUrl = $pageCss['url'] ?? null;
|
||||
$pageCssHash = $pageCss['hash'] ?? null;
|
||||
|
||||
// Check for cover image for social media
|
||||
$coverImage = findCoverImage($pageDir);
|
||||
$socialImageUrl = null;
|
||||
if ($coverImage) {
|
||||
$relativePath = str_replace($ctx->contentDir, '', $pageDir);
|
||||
$relativePath = trim($relativePath, '/');
|
||||
$socialImageUrl = '/' . ($relativePath ? $relativePath . '/' : '') . $coverImage;
|
||||
}
|
||||
|
||||
// Wrap content with page template
|
||||
ob_start();
|
||||
include $ctx->templates->page;
|
||||
|
|
|
|||
|
|
@ -142,6 +142,15 @@ switch ($parsedPath['type']) {
|
|||
$pageCssUrl = $pageCss['url'] ?? null;
|
||||
$pageCssHash = $pageCss['hash'] ?? null;
|
||||
|
||||
// Check for cover image for social media
|
||||
$coverImage = findCoverImage($dir);
|
||||
$socialImageUrl = null;
|
||||
if ($coverImage) {
|
||||
$relativePath = str_replace($ctx->contentDir, '', $dir);
|
||||
$relativePath = trim($relativePath, '/');
|
||||
$socialImageUrl = '/' . ($relativePath ? $relativePath . '/' : '') . $coverImage;
|
||||
}
|
||||
|
||||
include $ctx->templates->base;
|
||||
exit;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue