Commit af970b8b authored by Benjamin Bellamy's avatar Benjamin Bellamy 💬
Browse files

feat: add Open Graph and Twitter meta tags

fix: #41
parent 0e38dcca
Pipeline #417 passed with stage
in 4 minutes and 52 seconds
......@@ -50,6 +50,11 @@ class Episode extends Entity
*/
protected $enclosure_web_url;
/**
* @var string
*/
protected $enclosure_opengraph_url;
/**
* Holds text only description, striped of any markdown or html special characters
*
......@@ -220,6 +225,11 @@ class Episode extends Entity
return $this->getEnclosureUrl() . '?_from=-+Website+-';
}
public function getEnclosureOpengraphUrl()
{
return $this->getEnclosureUrl() . '?_from=-+Open+Graph+-';
}
public function getLink()
{
return base_url(
......
......@@ -20,3 +20,21 @@ if (!function_exists('host_url')) {
return false;
}
}
if (!function_exists('current_season_url')) {
/**
* Return the podcast URL with season number to use in views
*
* @return string
*/
function current_season_url()
{
$season_query_string = '';
if (isset($_GET['season'])) {
$season_query_string = '?season=' . $_GET['season'];
} elseif (isset($_GET['year'])) {
$season_query_string = '?year=' . $_GET['year'];
}
return current_url() . $season_query_string;
}
}
......@@ -9,7 +9,23 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
<link rel="stylesheet" href="/assets/index.css"/>
<link rel="canonical" href="<?= current_url() ?>" />
<script src="/assets/podcast.js" type="module" defer></script>
<meta property="og:title" content="<?= $episode->title ?>" />
<meta property="og:locale" content="<?= $podcast->language_code ?>" />
<meta property="og:site_name" content="<?= $podcast->title ?>" />
<meta property="og:url" content="<?= current_url() ?>" />
<meta property="article:published_time" content="<?= $episode->published_at ?>" />
<meta property="article:modified_time" content="<?= $episode->updated_at ?>" />
<meta property="og:image" content="<?= $episode->image->large_url ?>" />
<meta property="og:image:width" content="<?= config('Images')
->largeSize ?>" />
<meta property="og:image:height" content="<?= config('Images')
->largeSize ?>" />
<meta property="og:audio" content="<?= $episode->enclosure_opengraph_url ?>" />
<meta property="og:audio:type" content="<?= $episode->enclosure_mimetype ?>" />
<meta property="og:description" content="<?= $episode->description ?>" />
<meta name="twitter:card" content="summary_large_image" />
</head>
<body class="flex flex-col min-h-screen mx-auto">
......
......@@ -10,8 +10,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
<link rel="stylesheet" href="/assets/index.css"/>
<link rel="canonical" href="<?= current_season_url() ?>" />
<link type="application/rss+xml" rel="alternate" title="<?= $podcast->title ?>" href="<?= $podcast->feed_url ?>"/>
<script src="/assets/podcast.js" type="module" defer></script>
<meta property="og:title" content="<?= $podcast->title ?>" />
<meta property="og:locale" content="<?= $podcast->language_code ?>" />
<meta property="og:site_name" content="<?= $podcast->title ?>" />
<meta property="og:url" content="<?= current_season_url() ?>" />
<meta property="og:image" content="<?= $podcast->image->large_url ?>" />
<meta property="og:image:width" content="<?= config('Images')
->largeSize ?>" />
<meta property="og:image:height" content="<?= config('Images')
->largeSize ?>" />
<meta property="og:description" content="<?= $episode->description ?>" />
<meta name="twitter:card" content="summary_large_image" />
</head>
<body class="flex flex-col min-h-screen">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment