|
12 | 12 | { href: 'about.html', label: 'About' }, |
13 | 13 | { href: 'download.html', label: 'Download' }, |
14 | 14 | { href: 'documentation.html', label: 'Documentation' }, |
15 | | - { href: 'news.html', label: 'News' }, |
| 15 | + { href: 'https://github.com/OpenTOPAS/OpenTOPAS/discussions', label: 'User Forum', external: true }, |
16 | 16 | { href: 'publications.html', label: 'Publications' }, |
17 | 17 | { href: 'contact.html', label: 'Contact' }, |
18 | 18 | ]; |
19 | 19 |
|
20 | 20 | const currentPath = window.location.pathname.split('/').pop() || 'index.html'; |
21 | 21 | nav.innerHTML = navItems |
22 | | - .map(({ href, label }) => { |
23 | | - const isActive = currentPath === href; |
24 | | - const activeAttr = isActive ? ' aria-current="page"' : ''; |
25 | | - return `<a href="${href}"${activeAttr}>${label}</a>`; |
| 22 | + .map(({ href, label, external }) => { |
| 23 | + const isActive = !external && currentPath === href; |
| 24 | + const attrs = [ |
| 25 | + `href="${href}"`, |
| 26 | + external ? 'target="_blank"' : '', |
| 27 | + external ? 'rel="noopener"' : '', |
| 28 | + isActive ? 'aria-current="page"' : '', |
| 29 | + ] |
| 30 | + .filter(Boolean) |
| 31 | + .join(' '); |
| 32 | + const suffix = external ? ' <span class="external-icon" aria-hidden="true">↗</span>' : ''; |
| 33 | + return `<a ${attrs}>${label}${suffix}</a>`; |
26 | 34 | }) |
27 | 35 | .join(''); |
28 | 36 | } |
|
0 commit comments