Skip to content

Commit a2259ab

Browse files
committed
Specialize the breadcumbs for SimRel.
1 parent 65c3a20 commit a2259ab

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

markdown/index.html

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,35 @@ <h2>Table of Contents</h2>
368368
return false;
369369
}
370370

371+
const specializedBreadcrumpbs = [
372+
{pattern: /^eclipse-simrel\/.github\/main\/$/, replacement: {label: 'Eclipse SimRel', href: getMarkdownSearch('eclipse-simrel/.github\/main/profile/README.md')}},
373+
{pattern: /^eclipse-simrel\/.github\/main\/(profile\/?)?$/, replacement: null},
374+
{pattern: /^eclipse-simrel\/.github\/main\/profile\/README.md?$/, replacement: null},
375+
{pattern: /^eclipse-simrel\/.github\/main\/wiki\/?$/, replacement: {label: 'Wiki', href: getMarkdownSearch('eclipse-simrel/.github\/main/wiki/README.md')}},
376+
{pattern: /^eclipse-simrel\/.github\/main\/wiki\/README.md$/, replacement: null},
377+
{pattern: /^eclipse-simrel\/.github\/main\/wiki\/SimRel\/?$/, replacement: null},
378+
{pattern: /^eclipse-simrel\/.github\/main\/wiki\/?$/, replacement: {label: 'Wiki', href: getMarkdownSearch('eclipse-simrel/.github\/main/wiki/README.md')}},
379+
];
380+
381+
function generatBreadcrumbPath(crumbPath, segment) {
382+
const fullPath = `${org}/${repo}/${branch}${crumbPath}`;
383+
console.log(fullPath);
384+
385+
for (const matcher of specializedBreadcrumpbs) {
386+
const match = matcher.pattern.exec(fullPath);
387+
if (match != null) {
388+
console.log(match);
389+
const replacement = matcher.replacement;
390+
return replacement;
391+
}
392+
}
393+
394+
return {
395+
label: segment.length == 0 ? repoName : niceName(segment.replace(/\.md$/, '')),
396+
href: getMarkdownSearch(fullPath)
397+
};
398+
}
399+
371400
if (parts == null || parts.length == 0) {
372401
targetElement.innerHTML = 'No well-formed query parameter of the form <code>?file=org/repo/branch/path</code> has been specified.';
373402
} else {
@@ -391,8 +420,10 @@ <h2>Table of Contents</h2>
391420
let crumbPath = '';
392421
for (const segment of segments) {
393422
crumbPath = (crumbPath == '/' ? '/' : crumbPath + '/') + segment;
394-
const href = getMarkdownSearch(`${org}/${repo}/${branch}${crumbPath}`);
395-
breadcrumb.append(...toElements(`<li><a href="${href}">${segment.length == 0 ? repoName : niceName(segment.replace(/\.md$/, ''))}</a></li>`));
423+
const crumb = generatBreadcrumbPath(crumbPath, segment);
424+
if (crumb != null) {
425+
breadcrumb.append(...toElements(`<li><a href="${crumb.href}">${crumb.label}</a></li>`));
426+
}
396427
}
397428
}
398429

0 commit comments

Comments
 (0)