feat: profile_url auteur → article:author URL + JSON-LD author.url

This commit is contained in:
Cedric Abonnel
2026-05-12 23:45:41 +02:00
parent a031ea960e
commit e1c179b536
6 changed files with 53 additions and 16 deletions
+21 -6
View File
@@ -35,11 +35,21 @@ function currentUserName(): string
}
function authorDisplayName(string $email): string
{
return authorProfile($email)['name'];
}
function authorProfileUrl(string $email): string
{
return authorProfile($email)['url'];
}
function authorProfile(string $email): array
{
static $cache = [];
$key = strtolower(trim($email));
if ($key === '') {
return '';
return ['name' => '', 'url' => ''];
}
if (array_key_exists($key, $cache)) {
return $cache[$key];
@@ -47,15 +57,20 @@ function authorDisplayName(string $email): string
$pdo = dbPdo();
if ($pdo) {
try {
$st = $pdo->prepare('SELECT display_name FROM user_profiles WHERE email = :e');
$st = $pdo->prepare('SELECT display_name, profile_url FROM user_profiles WHERE email = :e');
$st->execute([':e' => $key]);
$name = $st->fetchColumn();
$cache[$key] = ($name !== false && $name !== '') ? $name : explode('@', $key)[0];
return $cache[$key];
$row = $st->fetch(PDO::FETCH_ASSOC);
if ($row) {
$cache[$key] = [
'name' => ($row['display_name'] !== '') ? $row['display_name'] : explode('@', $key)[0],
'url' => $row['profile_url'] ?? '',
];
return $cache[$key];
}
} catch (\Throwable) {
}
}
$cache[$key] = explode('@', $key)[0];
$cache[$key] = ['name' => explode('@', $key)[0], 'url' => ''];
return $cache[$key];
}