Add Open Graph tags functionality
This commit is contained in:
parent
6879fad5fb
commit
875408a27c
2 changed files with 27 additions and 0 deletions
|
|
@ -63,6 +63,15 @@ function renderFile(Context $ctx, string $filePath): void {
|
||||||
$pageCss = findPageCss($pageDir, $ctx->contentDir);
|
$pageCss = findPageCss($pageDir, $ctx->contentDir);
|
||||||
$pageCssUrl = $pageCss['url'] ?? null;
|
$pageCssUrl = $pageCss['url'] ?? null;
|
||||||
$pageCssHash = $pageCss['hash'] ?? 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
|
// Wrap content with page template
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
@ -106,6 +115,15 @@ function renderMultipleFiles(Context $ctx, array $filePaths, string $pageDir): v
|
||||||
$pageCss = findPageCss($pageDir, $ctx->contentDir);
|
$pageCss = findPageCss($pageDir, $ctx->contentDir);
|
||||||
$pageCssUrl = $pageCss['url'] ?? null;
|
$pageCssUrl = $pageCss['url'] ?? null;
|
||||||
$pageCssHash = $pageCss['hash'] ?? 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
|
// Wrap content with page template
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,15 @@ switch ($parsedPath['type']) {
|
||||||
$pageCss = findPageCss($dir, $ctx->contentDir);
|
$pageCss = findPageCss($dir, $ctx->contentDir);
|
||||||
$pageCssUrl = $pageCss['url'] ?? null;
|
$pageCssUrl = $pageCss['url'] ?? null;
|
||||||
$pageCssHash = $pageCss['hash'] ?? 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;
|
include $ctx->templates->base;
|
||||||
exit;
|
exit;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue