(list, latestArticles)
| 681 | } |
| 682 | |
| 683 | function renderFeaturedCards(list, latestArticles) { |
| 684 | if (latestArticles && latestArticles.length) { |
| 685 | renderLatestFeaturedCards(list, latestArticles); |
| 686 | return; |
| 687 | } |
| 688 | |
| 689 | Array.from(list.children).forEach(function (item) { |
| 690 | if (item.tagName !== 'LI' || item.classList.contains('home-reading-item')) { |
| 691 | return; |
| 692 | } |
| 693 | |
| 694 | var link = item.querySelector('a[href]'); |
| 695 | |
| 696 | if (!link) { |
| 697 | return; |
| 698 | } |
| 699 | |
| 700 | var markdownPath = toMarkdownPath(link.getAttribute('href') || ''); |
| 701 | |
| 702 | if (!markdownPath || !isArticleMarkdown(markdownPath)) { |
| 703 | return; |
| 704 | } |
| 705 | |
| 706 | var summaryNode = Array.from(item.querySelectorAll('p')).find(function (paragraph) { |
| 707 | return !paragraph.querySelector('a[href]'); |
| 708 | }); |
| 709 | |
| 710 | renderFeaturedCard({ |
| 711 | href: toRouteHref(markdownPath), |
| 712 | item: item, |
| 713 | markdownPath: markdownPath, |
| 714 | summary: summaryNode ? summaryNode.textContent.trim() : '', |
| 715 | title: link.textContent.trim() |
| 716 | }); |
| 717 | }); |
| 718 | } |
| 719 | |
| 720 | function renderLatestFeaturedCards(list, articles) { |
| 721 | var key = articles.map(function (article) { |
no test coverage detected