rss yandex full text remove image

This commit is contained in:
merdan 2021-10-11 18:19:31 +05:00
parent 2ba7a2614f
commit d4668355a8
4 changed files with 17 additions and 13 deletions

View File

@ -151,7 +151,7 @@ $this->page['language'] = \App::getLocale();
/*
* List all the posts, eager load their categories
*/
$posts = BlogPost::listFrontEnd([
$posts = BlogPost::with('categories')->listFrontEnd([
'sort' => $this->property('sortOrder'),
'perPage' => $this->property('postsPerPage'),
'category' => $category,

View File

@ -13,10 +13,10 @@
<link>{{ post.url }}</link>
<guid isPermaLink='true' >{{ post.url }}</guid>
<pubDate>{{ post.rss_date }}</pubDate>
<description><![CDATA[<img src="{{post.featured_image|media_cdn}}">{{ post.summary|raw}} ]]></description>
<enclosure
url="{{post.featured_image|media_cdn}}"
type="image/jpeg"/>
<description><![CDATA[{{ post.summary|raw}} ]]></description>
<enclosure
url="{{post.featured_image|media_cdn}}"
type="image/jpeg"/>
<content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/">
<![CDATA[ {{post.content_html|raw}} ]]>
</content:encoded>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:yandex="http://news.yandex.ru"
xmlns:yandex="http://news.yandex.ru"
xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>{{ this.page.meta_title ?: this.page.title }}{% if category %}:{{category.name}}{% endif %}</title>
@ -8,19 +8,20 @@
<description>{{ this.page.meta_description ?: this.page.description }}</description>
<atom:link href="{{ rssLink }}" rel="self" type="application/rss+xml" />
<language>{{language}}</language>
{% for post in posts %}
<item>
<title>{{ post.title }}</title>
<link>{{ post.url }}</link>
<pdalink>{{ post.url }}</pdalink>
<yandex:genre>article</yandex:genre>
<category>{{post.categories.first.name}}</category>
<guid isPermaLink='true' >{{ post.url }}</guid>
<pubDate>{{post.rss_date}}</pubDate>
<description><![CDATA[<img src="{{post.featured_image|media_cdn}}">{{ post.summary|raw}} ]]></description>
<enclosure
url="{{post.featured_image|media_cdn}}"
type="image/jpeg"/>
<yandex:full-text><![CDATA[ {{post.content_html|raw}} ]]></yandex:full-text>
<description><![CDATA[{{ post.summary|raw}} ]]></description>
<enclosure url="{{post.featured_image|media_cdn}}" type="image/jpeg"/>
<yandex:full-text><![CDATA[ {{post.full_text|raw}} ]]></yandex:full-text>
</item>
{% endfor %}
</channel>
</rss>
</rss>

View File

@ -481,6 +481,9 @@ class Post extends Model
return Html::limit($content, 280);
}
public function getFullTextAttribute(){
return preg_replace("/<img[^>]+\>/i", " ", $this->content_html);
}
public function getTranslatedPostAttribute(){
if($this->locale === 'en')
return $this->id_ru;