diff --git a/src/SiteSettings.php b/src/SiteSettings.php index 706d0bb..4a03b01 100644 --- a/src/SiteSettings.php +++ b/src/SiteSettings.php @@ -34,10 +34,15 @@ function siteClaim(): string return siteSettings()['site_claim'] ?? 'journal de Cédrix · informatique, hack & loisirs'; } +function siteAuthor(): string +{ + return siteSettings()['site_author'] ?? ''; +} + function saveSiteSettings(array $data): void { $current = siteSettings(); - $allowed = ['site_title', 'site_claim']; + $allowed = ['site_title', 'site_claim', 'site_author']; foreach ($allowed as $key) { if (array_key_exists($key, $data)) { $val = trim((string)$data[$key]); diff --git a/templates/admin.php b/templates/admin.php index 1ff4e54..5b966e4 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -352,6 +352,14 @@ function adminStatusBadge(array $a, int $now): string required maxlength="200">
Affiché sous le titre dans la navbar et dans le pied de page.
+
+ + +
Utilisé dans les métadonnées des articles (meta author, JSON-LD).
+
diff --git a/templates/layout.php b/templates/layout.php index 0fbf169..d7e7d4f 100644 --- a/templates/layout.php +++ b/templates/layout.php @@ -22,9 +22,15 @@ + + + + + + diff --git a/templates/post_view.php b/templates/post_view.php index 9977789..cd85ec9 100644 --- a/templates/post_view.php +++ b/templates/post_view.php @@ -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',