Description updates
This commit is contained in:
parent
5df4ac4c7f
commit
7a17716711
3 changed files with 22 additions and 10 deletions
20
index.php
20
index.php
|
|
@ -251,7 +251,7 @@ function article_og_image_url($articleId){
|
|||
if (!preg_match('/^[0-9]{14}[a-f0-9]{16}$/', $articleId)) return '';
|
||||
$path = __DIR__ . '/out-dir/' . $articleId . '_og.jpg';
|
||||
if (!is_file($path)) return '';
|
||||
return 'https://bubulescu.org/out-dir/' . rawurlencode($articleId . '_og.jpg');
|
||||
return 'https://bubulescu.org/out-dir/' . rawurlencode($articleId . '_og.jpg') . '?v=' . filemtime($path);
|
||||
}
|
||||
|
||||
function render_404_page(){
|
||||
|
|
@ -493,6 +493,7 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : [];
|
|||
$defaultOgImageUrl = 'https://bubulescu.org/assets/img/bubulescuorg.jpg';
|
||||
$ogImageUrl = $defaultOgImageUrl;
|
||||
$ogImageAlt = 'journal of an unreliable narrator.';
|
||||
$ogDescription = 'Motorcycle road stories, hockey passion, pizza nerdism and facts remembered by an unreliable narrator.';
|
||||
$ogType = ($articleId !== '') ? 'article' : 'website';
|
||||
$canonicalArticleUrl = ($articleId !== '') ? article_permalink_url($config, $articleId, $videoCache, true) : '';
|
||||
$ogUrl = ($canonicalArticleUrl !== '') ? $canonicalArticleUrl : 'https://bubulescu.org/';
|
||||
|
|
@ -510,6 +511,17 @@ if ($articleId !== '') {
|
|||
$ogImageAlt = $firstTitle;
|
||||
$pageTitle = $firstTitle;
|
||||
}
|
||||
$firstDescription = trim((string)($firstMeta['teaser'] ?? ''));
|
||||
if ($firstDescription === '') $firstDescription = trim((string)($firstMeta['description'] ?? ''));
|
||||
if ($firstDescription !== '') {
|
||||
$firstDescription = preg_replace('/\s+/', ' ', $firstDescription) ?? $firstDescription;
|
||||
if (function_exists('mb_strlen') && function_exists('mb_substr')) {
|
||||
if (mb_strlen($firstDescription) > 240) $firstDescription = rtrim(mb_substr($firstDescription, 0, 237)) . '…';
|
||||
} elseif (strlen($firstDescription) > 240) {
|
||||
$firstDescription = rtrim(substr($firstDescription, 0, 237)) . '...';
|
||||
}
|
||||
$ogDescription = $firstDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
$headerTitles = require __DIR__ . '/header_titles.php';
|
||||
|
|
@ -527,7 +539,7 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
|
|||
<!-- Basic Open Graph -->
|
||||
<meta property="og:type" content="<?=h($ogType)?>">
|
||||
<meta property="og:title" content="<?=h($ogImageAlt)?>">
|
||||
<meta property="og:description" content="Motorcycle road stories, hockey passion, pizza nerdism and facts remembered by an unreliable narrator.">
|
||||
<meta property="og:description" content="<?=h($ogDescription)?>">
|
||||
<meta property="og:url" content="<?=h($ogUrl)?>">
|
||||
<meta property="og:site_name" content="Bubulescu.Org">
|
||||
|
||||
|
|
@ -543,7 +555,7 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
|
|||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="<?=h($ogImageUrl)?>">
|
||||
<meta name="twitter:title" content="<?=h($ogImageAlt)?>">
|
||||
<meta name="twitter:description" content="Motorcycle road stories, hockey passion, pizza nerdism and facts remembered by an unreliable narrator.">
|
||||
<meta name="twitter:description" content="<?=h($ogDescription)?>">
|
||||
|
||||
<link rel="alternate" type="application/rss+xml" title="MVLog RSS" href="/feed.php">
|
||||
<link rel="icon" type="image/png" href="/assets/img/moto_travel.png">
|
||||
|
|
@ -631,7 +643,7 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
|
|||
$permalinkEnabled = $articleIdForVideo !== '' && article_permalink_enabled($config, $articleIdForVideo);
|
||||
$permalinkUrl = $permalinkEnabled ? article_permalink_url($config, $articleIdForVideo, $videoCache, false) : '';
|
||||
$shareUrl = $permalinkEnabled ? article_permalink_url($config, $articleIdForVideo, $videoCache, true) : '';
|
||||
$url = '/' . ltrim((string)$config['public_videos'], '/') . '/'.rawurlencode($name);
|
||||
$url = '/' . ltrim((string)$config['public_videos'], '/') . '/'.rawurlencode($name) . (is_file($v) ? '?v=' . filemtime($v) : '');
|
||||
$m = $videoCache[$name]['metadata'] ?? video_metadata($v);
|
||||
$posterUrl = video_thumb_public_url($config, $name);
|
||||
$dateFilterUrl = query_url(['q' => 'date=' . (string)($m['date'] ?? '')]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue