mirror of
https://github.com/typecho/typecho.git
synced 2025-04-21 02:01:52 +02:00
add open graph and twitter card support
add canonical link
This commit is contained in:
parent
7edd3f9659
commit
005951ee4d
@ -951,6 +951,7 @@ class Archive extends Contents
|
||||
'rss1' => $this->archiveFeedRssUrl,
|
||||
'commentReply' => 1,
|
||||
'antiSpam' => 1,
|
||||
'social' => 1,
|
||||
'atom' => $this->archiveFeedAtomUrl
|
||||
];
|
||||
|
||||
@ -965,22 +966,7 @@ class Archive extends Contents
|
||||
$allows = self::pluginHandle()->call('headerOptions', $allows, $this);
|
||||
$title = (empty($this->archiveTitle) ? '' : $this->archiveTitle . ' » ') . $this->options->title;
|
||||
|
||||
$header = '';
|
||||
if (!empty($allows['description'])) {
|
||||
$header .= '<meta name="description" content="' . $allows['description'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['keywords'])) {
|
||||
$header .= '<meta name="keywords" content="' . $allows['keywords'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['generator'])) {
|
||||
$header .= '<meta name="generator" content="' . $allows['generator'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['template'])) {
|
||||
$header .= '<meta name="template" content="' . $allows['template'] . '" />' . "\n";
|
||||
}
|
||||
$header = '<link rel="canonical" href="' . $this->archiveUrl . '" />' . "\n";
|
||||
|
||||
if (!empty($allows['pingback']) && 2 == $this->options->allowXmlRpc) {
|
||||
$header .= '<link rel="pingback" href="' . $allows['pingback'] . '" />' . "\n";
|
||||
@ -1011,6 +997,34 @@ class Archive extends Contents
|
||||
. $title . ' » ATOM 1.0" href="' . $allows['atom'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['description'])) {
|
||||
$header .= '<meta name="description" content="' . $allows['description'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['keywords'])) {
|
||||
$header .= '<meta name="keywords" content="' . $allows['keywords'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['generator'])) {
|
||||
$header .= '<meta name="generator" content="' . $allows['generator'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['template'])) {
|
||||
$header .= '<meta name="template" content="' . $allows['template'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($allows['social'])) {
|
||||
$header .= '<meta property="og:type" content="' . ($this->is('single') ? 'article' : 'website') . '" />' . "\n";
|
||||
$header .= '<meta property="og:url" content="' . $this->archiveUrl . '" />' . "\n";
|
||||
$header .= '<meta name="twitter:title" property="og:title" itemprop="name" content="'
|
||||
. htmlspecialchars($this->archiveTitle ?? $this->options->title) . '" />' . "\n";
|
||||
$header .= '<meta name="twitter:description" property="og:description" itemprop="description" content="'
|
||||
. htmlspecialchars($this->archiveDescription ?? $this->options->description) . '" />' . "\n";
|
||||
$header .= '<meta property="og:site_name" content="' . htmlspecialchars($this->options->title) . '" />' . "\n";
|
||||
$header .= '<meta name="twitter:card" content="summary" />' . "\n";
|
||||
$header .= '<meta name="twitter:domain" content="' . $this->options->siteDomain . '" />' . "\n";
|
||||
}
|
||||
|
||||
if ($this->options->commentsThreaded && $this->is('single')) {
|
||||
if ('' != $allows['commentReply']) {
|
||||
if (1 == $allows['commentReply']) {
|
||||
|
@ -29,6 +29,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
|
||||
* @property string $xmlRpcUrl
|
||||
* @property string $index
|
||||
* @property string $siteUrl
|
||||
* @property string $siteDomain
|
||||
* @property array $routingTable
|
||||
* @property string $rootUrl
|
||||
* @property string $pluginUrl
|
||||
@ -453,6 +454,14 @@ class Options extends Base
|
||||
return $siteUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function ___siteDomain(): string
|
||||
{
|
||||
return parse_url($this->siteUrl, PHP_URL_HOST);
|
||||
}
|
||||
|
||||
/**
|
||||
* RSS2.0
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user