(markdown, articleRoot)
| 544 | } |
| 545 | |
| 546 | function extractArticleIndex(markdown, articleRoot) { |
| 547 | var articles = []; |
| 548 | var pattern = /^\s*-\s*(\d{4}-\d{2}-\d{2})\s*-\s*\[([^\]]+)\]\(([^)]+)\)/gm; |
| 549 | var match; |
| 550 | |
| 551 | while ((match = pattern.exec(markdown))) { |
| 552 | var markdownPath = resolveIndexMarkdownPath(match[3], articleRoot); |
| 553 | |
| 554 | if (!isArticleMarkdown(markdownPath)) { |
| 555 | continue; |
| 556 | } |
| 557 | |
| 558 | articles.push({ |
| 559 | date: match[1], |
| 560 | href: toRouteHref(markdownPath), |
| 561 | markdownPath: markdownPath, |
| 562 | title: match[2].trim() |
| 563 | }); |
| 564 | } |
| 565 | |
| 566 | return articles; |
| 567 | } |
| 568 | |
| 569 | function resolveIndexMarkdownPath(href, articleRoot) { |
| 570 | articleRoot = articleRoot || 'ai-articles'; |
no test coverage detected