mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
Add document tags and hashtags to og:article:tag
This commit is contained in:
parent
7eed765ec5
commit
e4fb4e1dbf
7 changed files with 39 additions and 2 deletions
|
|
@ -523,11 +523,36 @@ class HTMLDisplayHandler
|
|||
}
|
||||
}
|
||||
|
||||
// Add tags and hashtags for articles.
|
||||
if ($page_type === 'article')
|
||||
{
|
||||
$tags = array_unique(array_map('utf8_trim', explode(',', $oDocument->get('tags'))));
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
if ($tag !== '')
|
||||
{
|
||||
Context::addOpenGraphData('og:article:tag', escape($tag, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (config('seo.og_extract_hashtags'))
|
||||
{
|
||||
preg_match_all('/#([\pL\pN_]+)/u', strip_tags($oDocument->get('content')), $hashtags);
|
||||
foreach ($hashtags[1] as $hashtag)
|
||||
{
|
||||
if (!in_array($hashtag, $tags))
|
||||
{
|
||||
Context::addOpenGraphData('og:article:tag', escape($hashtag, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add datetime for articles.
|
||||
if ($page_type === 'article' && config('seo.og_use_timestamps'))
|
||||
{
|
||||
Context::addOpenGraphData('article:published_time', $oDocument->getRegdate('c'));
|
||||
Context::addOpenGraphData('article:modified_time', $oDocument->getUpdate('c'));
|
||||
Context::addOpenGraphData('og:article:published_time', $oDocument->getRegdate('c'));
|
||||
Context::addOpenGraphData('og:article:modified_time', $oDocument->getUpdate('c'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue