feat: meta author + site_author configurable depuis /admin/site

This commit is contained in:
Cedric Abonnel
2026-05-12 23:40:21 +02:00
parent fb14d7c842
commit 6b32eccebe
4 changed files with 25 additions and 3 deletions
+8
View File
@@ -352,6 +352,14 @@ function adminStatusBadge(array $a, int $now): string
required maxlength="200">
<div class="form-text">Affiché sous le titre dans la navbar et dans le pied de page.</div>
</div>
<div class="mb-3">
<label for="site-author" class="form-label small fw-semibold">Auteur principal</label>
<input type="text" id="site-author" name="site_author"
class="form-control form-control-sm"
value="<?= htmlspecialchars(siteAuthor()) ?>"
maxlength="100" placeholder="ex : Cédrix">
<div class="form-text">Utilisé dans les métadonnées des articles (meta author, JSON-LD).</div>
</div>
<button type="submit" class="btn btn-primary btn-sm">Enregistrer</button>
</form>
</div>
+6
View File
@@ -22,9 +22,15 @@
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<?php endif; ?>
<?php if (!empty($metaAuthor ?? '')): ?>
<meta name="author" content="<?= htmlspecialchars($metaAuthor) ?>">
<?php endif; ?>
<?php if (!empty($articlePublishedAt ?? '')): ?>
<meta property="article:published_time" content="<?= htmlspecialchars(date('c', strtotime((string)$articlePublishedAt))) ?>">
<?php endif; ?>
<?php if (!empty($metaAuthor ?? '')): ?>
<meta property="article:author" content="<?= htmlspecialchars($metaAuthor) ?>">
<?php endif; ?>
<?php if (!empty($jsonLd ?? '')): ?>
<script type="application/ld+json"><?= $jsonLd ?></script>
+5 -2
View File
@@ -281,6 +281,9 @@ if ($ogImage === null || $ogImage === '') {
$ogImage = $article['og_image'] ?? '';
}
// Auteur : nom affiché de l'article, sinon auteur du site
$metaAuthor = $authorName !== '' ? $authorName : siteAuthor();
// JSON-LD Article
$jsonLdData = [
'@context' => 'https://schema.org',
@@ -290,10 +293,10 @@ $jsonLdData = [
'url' => $canonical,
'datePublished' => date('c', strtotime((string)$articlePublishedAt)),
'dateModified' => date('c', strtotime((string)($article['updated_at'] ?? $articlePublishedAt))),
'author' => ['@type' => 'Person', 'name' => 'Cédrix'],
'author' => ['@type' => 'Person', 'name' => $metaAuthor !== '' ? $metaAuthor : siteTitle()],
'publisher' => [
'@type' => 'Person',
'name' => 'Cédrix',
'name' => siteAuthor() !== '' ? siteAuthor() : siteTitle(),
'url' => rtrim(APP_URL, '/'),
],
'inLanguage' => 'fr-FR',