mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 03:56:19 +00:00
Merge pull request #1 from jahglow/master
Базовая поддержка yandex:related
This commit is contained in:
19
lib/index.js
19
lib/index.js
@@ -43,6 +43,22 @@ function generateXML(data) {
|
||||
let fullContent = '<header>' + img + ' <h1>' + item.title + '</h1>' + menu + '</header>' + item.content;
|
||||
|
||||
item_values.push({'turbo:content': {_cdata: fullContent}});
|
||||
|
||||
let relatedLink = function(related) {
|
||||
return (
|
||||
'<link url="' +
|
||||
related.url +
|
||||
'" img="' +
|
||||
related.image_url +
|
||||
'">' +
|
||||
related.text +
|
||||
'</link>'
|
||||
);
|
||||
};
|
||||
ifTruePush(item.related, item_values, {
|
||||
'yandex:related': item.related.map(relatedLink).join('')
|
||||
});
|
||||
|
||||
channel.push({item: item_values});
|
||||
|
||||
});
|
||||
@@ -80,7 +96,8 @@ function YTurbo(options, items) {
|
||||
author: options.author,
|
||||
date: options.date || options.pubDate,
|
||||
content: options.content,
|
||||
menu: options.menu
|
||||
menu: options.menu,
|
||||
related: options.related
|
||||
};
|
||||
|
||||
this.items.push(item);
|
||||
|
||||
12
readme.md
12
readme.md
@@ -44,6 +44,7 @@ feed.item(itemOptions);
|
||||
* `author` _optional_ **string** Автор статьи, размещенной на странице.
|
||||
* `date` **string** Время публикации контента на сайте источника.
|
||||
* `content` **string** Содержимое страницы
|
||||
* `related` _optional_ **object** Содержимое страницы
|
||||
|
||||
*Будет добавлено в новых версиях turbo:source, turbo:topic, yandex:related, menu, pubDate как алиас date*
|
||||
|
||||
@@ -73,7 +74,16 @@ feed.item({
|
||||
url: 'http://example.com/article4?this&that',
|
||||
author: 'LightAir',
|
||||
date: 'May 27, 2012',
|
||||
content: '<p>hello</p>'
|
||||
content: '<p>hello</p>',
|
||||
related: [{
|
||||
link: 'http://example.com/related/post1',
|
||||
image_url: 'http://example.com/i/img1.jpg',
|
||||
text: 'related link text 1'
|
||||
}, {
|
||||
link: 'http://example.com/related/post2',
|
||||
image_url: 'http://example.com/i/img2.jpg',
|
||||
text: 'related link text 2'
|
||||
}]
|
||||
});
|
||||
|
||||
// cache the xml to send to clients
|
||||
|
||||
Reference in New Issue
Block a user