feat: ajout metadonnees opengraph
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Kazhnuz 2024-11-28 11:04:11 +01:00
parent 1c30bfbd5a
commit 5234ef75d1
4 changed files with 37 additions and 0 deletions

View file

@ -8,6 +8,9 @@
<!-- Dynamic description tag -->
<?php echo Theme::metaTags('description'); ?>
<!-- Diverse meta tags -->
<?php include(THEME_DIR_PHP.'meta.php'); ?>
<!-- Include Favicon -->
<?php echo Theme::favicon('img/favicon.png'); ?>

14
php/meta.php Normal file
View file

@ -0,0 +1,14 @@
<?php
// Bludit content are pages
// But if you order the content by date
// These pages works as posts
// $WHERE_AM_I variable detect where the user is browsing
// If the user is watching a particular page/post the variable takes the value "page"
// If the user is watching the frontpage the variable takes the value "home"
if ($WHERE_AM_I == 'page') {
include(THEME_DIR_PHP.'meta/page.php');
} else {
include(THEME_DIR_PHP.'meta/home.php');
}
?>

5
php/meta/home.php Normal file
View file

@ -0,0 +1,5 @@
<meta property="og:type" content="website" />
<meta property="og:url" content="https://quarante-douze.net/" />
<meta property="og:title" content="<?php echo $site->title() ?>" />
<meta property="og:description" content="<?php echo $site->description() ?>" />
<meta property="og:image" content="<?php echo Theme::siteUrl() ?><?php echo HTML_PATH_THEME_IMG; ?>/default-preview.png" />

15
php/meta/page.php Normal file
View file

@ -0,0 +1,15 @@
<?php Theme::plugins('pageBegin'); ?>
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php echo $page->permalink(); ?>" />
<meta property="og:title" content="<?php echo $page->title(); ?> | <?php echo $site->title() ?>" />
<meta property="og:description" content="<?php echo $page->description(); ?>" />
<?php if ($page->coverImage()) : ?>
<meta property="og:image" content="<?php echo $page->coverImage(); ?>" />
<?php else : ?>
<meta property="og:image" content="<?php echo Theme::siteUrl() ?><?php echo HTML_PATH_THEME_IMG; ?>/default-preview.png" />
<?php endif ?>
<meta property="article:published_time" content="<?php echo $page->date(DATE_ATOM) ?>" />
<meta property="article:author:username" content="<?php echo $page->user('nickname'); ?>" />
<!-- TODO: rendre ça paramétrable -->
<meta property="fediverse:author" name="fediverse:author" content="kazhnuz@toot.kobold.cafe" />
<?php Theme::plugins('pageEnd'); ?>