From 365abd559289d8372b888099b35fe1569d9fbead Mon Sep 17 00:00:00 2001 From: "Ivan Pilyugin (aka Archer)" Date: Tue, 29 May 2018 09:58:53 +0300 Subject: [PATCH 1/3] added yandex:related support --- lib/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index e735a37..8103df5 100755 --- a/lib/index.js +++ b/lib/index.js @@ -43,6 +43,22 @@ function generateXML(data) { let fullContent = '
' + img + '

' + item.title + '

' + menu + '
' + item.content; item_values.push({'turbo:content': {_cdata: fullContent}}); + + let relatedLink = function(related) { + return ( + '' + + related.text + + '' + ); + }; + 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); From c47a6d3d0f1cd83185b370a98d1e09bb27885758 Mon Sep 17 00:00:00 2001 From: "Ivan Pilyugin (aka Archer)" Date: Tue, 29 May 2018 10:03:41 +0300 Subject: [PATCH 2/3] Update readme.md added description to yandex:related --- readme.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 8867786..f74e4c5 100644 --- a/readme.md +++ b/readme.md @@ -44,7 +44,8 @@ feed.item(itemOptions); * `author` _optional_ **string** Автор статьи, размещенной на странице. * `date` **string** Время публикации контента на сайте источника. * `content` **string** Содержимое страницы - + * `related` _optional_ **object** Содержимое страницы + *Будет добавлено в новых версиях turbo:source, turbo:topic, yandex:related, menu, pubDate как алиас date* ##### Получение XML @@ -73,7 +74,16 @@ feed.item({ url: 'http://example.com/article4?this&that', author: 'LightAir', date: 'May 27, 2012', - content: '

hello

' + content: '

hello

', + 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 From 10e74b0a1b3e30f8399c0e82f762fd9adbdeed99 Mon Sep 17 00:00:00 2001 From: "Ivan Pilyugin (aka Archer)" Date: Tue, 29 May 2018 10:04:50 +0300 Subject: [PATCH 3/3] yandex:related image renamed to image_url for naming consistency --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 8103df5..34967c4 100755 --- a/lib/index.js +++ b/lib/index.js @@ -49,7 +49,7 @@ function generateXML(data) { '' + related.text + ''