From 005951ee4dcb790ceba10473fa38190c5381d0df Mon Sep 17 00:00:00 2001 From: joyqi Date: Fri, 29 Dec 2023 14:31:39 +0800 Subject: [PATCH] add open graph and twitter card support add canonical link --- var/Widget/Archive.php | 46 +++++++++++++++++++++++++++--------------- var/Widget/Options.php | 9 +++++++++ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index 1b83eb21..95aff2ef 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -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 .= '' . "\n"; - } - - if (!empty($allows['keywords'])) { - $header .= '' . "\n"; - } - - if (!empty($allows['generator'])) { - $header .= '' . "\n"; - } - - if (!empty($allows['template'])) { - $header .= '' . "\n"; - } + $header = '' . "\n"; if (!empty($allows['pingback']) && 2 == $this->options->allowXmlRpc) { $header .= '' . "\n"; @@ -1011,6 +997,34 @@ class Archive extends Contents . $title . ' » ATOM 1.0" href="' . $allows['atom'] . '" />' . "\n"; } + if (!empty($allows['description'])) { + $header .= '' . "\n"; + } + + if (!empty($allows['keywords'])) { + $header .= '' . "\n"; + } + + if (!empty($allows['generator'])) { + $header .= '' . "\n"; + } + + if (!empty($allows['template'])) { + $header .= '' . "\n"; + } + + if (!empty($allows['social'])) { + $header .= '' . "\n"; + $header .= '' . "\n"; + $header .= '' . "\n"; + $header .= '' . "\n"; + $header .= '' . "\n"; + $header .= '' . "\n"; + $header .= '' . "\n"; + } + if ($this->options->commentsThreaded && $this->is('single')) { if ('' != $allows['commentReply']) { if (1 == $allows['commentReply']) { diff --git a/var/Widget/Options.php b/var/Widget/Options.php index 70f9c3f5..18da0cb9 100644 --- a/var/Widget/Options.php +++ b/var/Widget/Options.php @@ -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 *