MCPcopy Create free account
hub / github.com/crisxuan/bestJavaer / resolveIndexMarkdownPath

Function resolveIndexMarkdownPath

assets/article-cards.js:569–593  ·  view source on GitHub ↗
(href, articleRoot)

Source from the content-addressed store, hash-verified

567 }
568
569 function resolveIndexMarkdownPath(href, articleRoot) {
570 articleRoot = articleRoot || 'ai-articles';
571
572 var cleanHref = (href || '').split('?')[0].split('#')[0].trim();
573
574 if (!cleanHref || /^(https?:|mailto:)/i.test(cleanHref)) {
575 return '';
576 }
577
578 if (cleanHref.indexOf('#/') === 0) {
579 return toMarkdownPath(cleanHref);
580 }
581
582 if (cleanHref.indexOf('./') === 0) {
583 cleanHref = articleRoot + '/' + cleanHref.slice(2);
584 } else if (cleanHref.indexOf(articleRoot + '/') !== 0) {
585 cleanHref = articleRoot + '/' + cleanHref.replace(/^\/+/, '');
586 }
587
588 if (!/\.md$/i.test(cleanHref)) {
589 cleanHref += '.md';
590 }
591
592 return cleanHref.replace(/^\/+/, '');
593 }
594
595 function decorateHomePage(section) {
596 var latestArticles = collectHomeUpdateArticles(section).slice(0, 6);

Callers 1

extractArticleIndexFunction · 0.85

Calls 1

toMarkdownPathFunction · 0.85

Tested by

no test coverage detected