mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
Add Open Graph and Twitter Card meta tags to all public pages
- templates/public/head.php: add centralised OG/Twitter tag rendering via $ogTags array; supports type, title, description, url, image, image_alt, site_name, article_author, article_published_time; twitter:card switches between summary_large_image / summary based on presence of og:image - public/tfe.php: populate full article OG tags — og:type=article, canonical URL, og:image resolved from banner_path → first image file in thesis_files → omitted, og:image:alt, article:author, article:published_time (year-01-01); twitter:card summary_large_image when image present - public/index.php, search.php, apropos.php, licence.php: add basic og:type=website tags (title, description, canonical url, site_name) Sharing a thesis link on Slack, WhatsApp, iMessage, or any social platform will now render a rich preview card with the thesis title, synopsis excerpt, and cover/banner image.
This commit is contained in:
@@ -26,6 +26,13 @@ $pd->setSafeMode(true);
|
||||
$aboutHtml = $pd->text($rawContent);
|
||||
$pageTitle = 'À Propos – Posterg';
|
||||
$metaDescription = 'À propos de Posterg, le répertoire des mémoires de fin d\'études de l\'erg – École de Recherches Graphiques de Bruxelles.';
|
||||
$ogTags = [
|
||||
'type' => 'website',
|
||||
'title' => $pageTitle,
|
||||
'description' => $metaDescription,
|
||||
'url' => 'https://posterg.erg.be/apropos.php',
|
||||
'site_name' => 'Posterg – ERG',
|
||||
];
|
||||
$extraCss = ['assets/apropos.css'];
|
||||
?>
|
||||
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||
|
||||
@@ -52,6 +52,13 @@ try {
|
||||
$currentNav = '';
|
||||
$pageTitle = 'Posterg – Mémoires de l\'ERG';
|
||||
$metaDescription = 'Posterg répertorie et valorise les mémoires de fin d\'études (TFE) de l\'erg – École de Recherches Graphiques de Bruxelles.';
|
||||
$ogTags = [
|
||||
'type' => 'website',
|
||||
'title' => $pageTitle,
|
||||
'description' => $metaDescription,
|
||||
'url' => 'https://posterg.erg.be/',
|
||||
'site_name' => 'Posterg – ERG',
|
||||
];
|
||||
$extraCss = ['assets/main.css'];
|
||||
?>
|
||||
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||
|
||||
@@ -22,6 +22,13 @@ $html = $pd->text($content);
|
||||
|
||||
$pageTitle = $licencePageTitle . ' – Posterg';
|
||||
$metaDescription = 'Informations sur les licences d\'utilisation des mémoires publiés sur Posterg, le répertoire des TFE de l\'erg.';
|
||||
$ogTags = [
|
||||
'type' => 'website',
|
||||
'title' => $pageTitle,
|
||||
'description' => $metaDescription,
|
||||
'url' => 'https://posterg.erg.be/licence.php',
|
||||
'site_name' => 'Posterg – ERG',
|
||||
];
|
||||
$extraCss = ['assets/apropos.css'];
|
||||
?>
|
||||
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||
|
||||
@@ -63,6 +63,13 @@ $currentNav = 'repertoire';
|
||||
$searchBarValue = $_GET['query'] ?? '';
|
||||
$pageTitle = 'Répertoire – Posterg';
|
||||
$metaDescription = 'Parcourez le répertoire des mémoires de fin d\'études (TFE) de l\'erg – École de Recherches Graphiques de Bruxelles. Recherche par année, orientation, atelier et mots-clés.';
|
||||
$ogTags = [
|
||||
'type' => 'website',
|
||||
'title' => $pageTitle,
|
||||
'description' => $metaDescription,
|
||||
'url' => 'https://posterg.erg.be/search.php',
|
||||
'site_name' => 'Posterg – ERG',
|
||||
];
|
||||
$extraCss = ['assets/search.css'];
|
||||
?>
|
||||
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||
|
||||
@@ -25,6 +25,37 @@ $metaDescription = mb_strlen($_synopsisRaw) > 160
|
||||
? mb_substr($_synopsisRaw, 0, 157) . '…'
|
||||
: (empty($_synopsisRaw) ? 'Mémoire de fin d\'études – Posterg, répertoire des TFE de l\'erg.' : $_synopsisRaw);
|
||||
unset($_tfeAuthor, $_synopsisRaw);
|
||||
|
||||
// --- Open Graph / Twitter Card tags ------------------------------------------
|
||||
$_ogBaseUrl = 'https://posterg.erg.be';
|
||||
// Resolve OG image: banner → first image file → none
|
||||
$_ogImage = '';
|
||||
if (!empty($data['banner_path'])) {
|
||||
$_ogImage = $_ogBaseUrl . '/media.php?path=' . rawurlencode($data['banner_path']);
|
||||
} elseif (!empty($data['files'])) {
|
||||
foreach ($data['files'] as $_f) {
|
||||
$_ext = strtolower(pathinfo($_f['file_path'], PATHINFO_EXTENSION));
|
||||
if (in_array($_ext, ['jpg', 'jpeg', 'png', 'gif', 'webp'])) {
|
||||
$_ogImage = $_ogBaseUrl . '/media.php?path=' . rawurlencode($_f['file_path']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($_f, $_ext);
|
||||
}
|
||||
$ogTags = [
|
||||
'type' => 'article',
|
||||
'title' => $data['title'] . (!empty($data['authors']) ? ' – ' . $data['authors'] : ''),
|
||||
'description' => $metaDescription,
|
||||
'url' => $_ogBaseUrl . '/tfe.php?id=' . $thesisId,
|
||||
'image' => $_ogImage,
|
||||
'image_alt' => $data['title'] . (!empty($data['authors']) ? ' par ' . $data['authors'] : ''),
|
||||
'site_name' => 'Posterg – ERG',
|
||||
'article_author' => $data['authors'] ?? '',
|
||||
'article_published_time' => !empty($data['year']) ? $data['year'] . '-01-01' : '',
|
||||
];
|
||||
unset($_ogBaseUrl, $_ogImage);
|
||||
// --- End Open Graph ----------------------------------------------------------
|
||||
|
||||
$extraCss = ['assets/tfe.css'];
|
||||
?>
|
||||
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||
|
||||
Reference in New Issue
Block a user