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:
@@ -7,6 +7,47 @@
|
||||
<?php if (!empty($metaDescription)): ?>
|
||||
<meta name="description" content="<?= htmlspecialchars($metaDescription) ?>">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
// Open Graph / Twitter Card tags — populated per-page via $ogTags array.
|
||||
// Keys: type, title, description, url, image, image_alt, site_name, article_author, article_published_time
|
||||
if (!empty($ogTags)):
|
||||
$ogType = $ogTags['type'] ?? 'website';
|
||||
$ogTitle = $ogTags['title'] ?? ($pageTitle ?? 'Posterg');
|
||||
$ogDescription = $ogTags['description'] ?? ($metaDescription ?? '');
|
||||
$ogUrl = $ogTags['url'] ?? '';
|
||||
$ogImage = $ogTags['image'] ?? '';
|
||||
$ogImageAlt = $ogTags['image_alt'] ?? $ogTitle;
|
||||
$ogSiteName = $ogTags['site_name'] ?? 'Posterg – ERG';
|
||||
?>
|
||||
<meta property="og:type" content="<?= htmlspecialchars($ogType) ?>">
|
||||
<meta property="og:site_name" content="<?= htmlspecialchars($ogSiteName) ?>">
|
||||
<meta property="og:title" content="<?= htmlspecialchars($ogTitle) ?>">
|
||||
<?php if (!empty($ogDescription)): ?>
|
||||
<meta property="og:description" content="<?= htmlspecialchars($ogDescription) ?>">
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ogUrl)): ?>
|
||||
<meta property="og:url" content="<?= htmlspecialchars($ogUrl) ?>">
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ogImage)): ?>
|
||||
<meta property="og:image" content="<?= htmlspecialchars($ogImage) ?>">
|
||||
<meta property="og:image:alt" content="<?= htmlspecialchars($ogImageAlt) ?>">
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ogTags['article_author'])): ?>
|
||||
<meta property="article:author" content="<?= htmlspecialchars($ogTags['article_author']) ?>">
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ogTags['article_published_time'])): ?>
|
||||
<meta property="article:published_time" content="<?= htmlspecialchars($ogTags['article_published_time']) ?>">
|
||||
<?php endif; ?>
|
||||
<meta name="twitter:card" content="<?= !empty($ogImage) ? 'summary_large_image' : 'summary' ?>">
|
||||
<meta name="twitter:title" content="<?= htmlspecialchars($ogTitle) ?>">
|
||||
<?php if (!empty($ogDescription)): ?>
|
||||
<meta name="twitter:description" content="<?= htmlspecialchars($ogDescription) ?>">
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ogImage)): ?>
|
||||
<meta name="twitter:image" content="<?= htmlspecialchars($ogImage) ?>">
|
||||
<meta name="twitter:image:alt" content="<?= htmlspecialchars($ogImageAlt) ?>">
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
|
||||
<link rel="stylesheet" href="assets/modern-normalize.min.css">
|
||||
<link rel="stylesheet" href="assets/common.css">
|
||||
|
||||
Reference in New Issue
Block a user