feat: meta author + site_author configurable depuis /admin/site
This commit is contained in:
@@ -34,10 +34,15 @@ function siteClaim(): string
|
|||||||
return siteSettings()['site_claim'] ?? 'journal de Cédrix · informatique, hack & loisirs';
|
return siteSettings()['site_claim'] ?? 'journal de Cédrix · informatique, hack & loisirs';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function siteAuthor(): string
|
||||||
|
{
|
||||||
|
return siteSettings()['site_author'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
function saveSiteSettings(array $data): void
|
function saveSiteSettings(array $data): void
|
||||||
{
|
{
|
||||||
$current = siteSettings();
|
$current = siteSettings();
|
||||||
$allowed = ['site_title', 'site_claim'];
|
$allowed = ['site_title', 'site_claim', 'site_author'];
|
||||||
foreach ($allowed as $key) {
|
foreach ($allowed as $key) {
|
||||||
if (array_key_exists($key, $data)) {
|
if (array_key_exists($key, $data)) {
|
||||||
$val = trim((string)$data[$key]);
|
$val = trim((string)$data[$key]);
|
||||||
|
|||||||
@@ -352,6 +352,14 @@ function adminStatusBadge(array $a, int $now): string
|
|||||||
required maxlength="200">
|
required maxlength="200">
|
||||||
<div class="form-text">Affiché sous le titre dans la navbar et dans le pied de page.</div>
|
<div class="form-text">Affiché sous le titre dans la navbar et dans le pied de page.</div>
|
||||||
</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>
|
<button type="submit" class="btn btn-primary btn-sm">Enregistrer</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,9 +22,15 @@
|
|||||||
<meta property="og:image:width" content="1200">
|
<meta property="og:image:width" content="1200">
|
||||||
<meta property="og:image:height" content="630">
|
<meta property="og:image:height" content="630">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if (!empty($metaAuthor ?? '')): ?>
|
||||||
|
<meta name="author" content="<?= htmlspecialchars($metaAuthor) ?>">
|
||||||
|
<?php endif; ?>
|
||||||
<?php if (!empty($articlePublishedAt ?? '')): ?>
|
<?php if (!empty($articlePublishedAt ?? '')): ?>
|
||||||
<meta property="article:published_time" content="<?= htmlspecialchars(date('c', strtotime((string)$articlePublishedAt))) ?>">
|
<meta property="article:published_time" content="<?= htmlspecialchars(date('c', strtotime((string)$articlePublishedAt))) ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if (!empty($metaAuthor ?? '')): ?>
|
||||||
|
<meta property="article:author" content="<?= htmlspecialchars($metaAuthor) ?>">
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if (!empty($jsonLd ?? '')): ?>
|
<?php if (!empty($jsonLd ?? '')): ?>
|
||||||
<script type="application/ld+json"><?= $jsonLd ?></script>
|
<script type="application/ld+json"><?= $jsonLd ?></script>
|
||||||
|
|||||||
@@ -281,6 +281,9 @@ if ($ogImage === null || $ogImage === '') {
|
|||||||
$ogImage = $article['og_image'] ?? '';
|
$ogImage = $article['og_image'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auteur : nom affiché de l'article, sinon auteur du site
|
||||||
|
$metaAuthor = $authorName !== '' ? $authorName : siteAuthor();
|
||||||
|
|
||||||
// JSON-LD Article
|
// JSON-LD Article
|
||||||
$jsonLdData = [
|
$jsonLdData = [
|
||||||
'@context' => 'https://schema.org',
|
'@context' => 'https://schema.org',
|
||||||
@@ -290,10 +293,10 @@ $jsonLdData = [
|
|||||||
'url' => $canonical,
|
'url' => $canonical,
|
||||||
'datePublished' => date('c', strtotime((string)$articlePublishedAt)),
|
'datePublished' => date('c', strtotime((string)$articlePublishedAt)),
|
||||||
'dateModified' => date('c', strtotime((string)($article['updated_at'] ?? $articlePublishedAt))),
|
'dateModified' => date('c', strtotime((string)($article['updated_at'] ?? $articlePublishedAt))),
|
||||||
'author' => ['@type' => 'Person', 'name' => 'Cédrix'],
|
'author' => ['@type' => 'Person', 'name' => $metaAuthor !== '' ? $metaAuthor : siteTitle()],
|
||||||
'publisher' => [
|
'publisher' => [
|
||||||
'@type' => 'Person',
|
'@type' => 'Person',
|
||||||
'name' => 'Cédrix',
|
'name' => siteAuthor() !== '' ? siteAuthor() : siteTitle(),
|
||||||
'url' => rtrim(APP_URL, '/'),
|
'url' => rtrim(APP_URL, '/'),
|
||||||
],
|
],
|
||||||
'inLanguage' => 'fr-FR',
|
'inLanguage' => 'fr-FR',
|
||||||
|
|||||||
Reference in New Issue
Block a user