Skip to content

Commit 0034462

Browse files
it all builds and runs and looks correct with these changes
1 parent 78c218f commit 0034462

11 files changed

Lines changed: 77 additions & 17 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
node-version: 20
2323
cache: npm
2424

25-
- name: Determine version and base href
25+
- name: Determine version
2626
id: version
2727
run: |
2828
PROD_VERSION=$(curl -sf https://reactome.org/ContentService/data/database/version)
@@ -42,7 +42,7 @@ jobs:
4242
- name: Build
4343
run: |
4444
npx ng build reactome-cytoscape-style
45-
npx ng build reactome --configuration production --base-href /${{ steps.version.outputs.version }}/website/
45+
npx ng build reactome --configuration production
4646
4747
- name: Configure AWS credentials
4848
uses: aws-actions/configure-aws-credentials@v4
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1 class="news-title">Latest News</h1>
22
<ul class="news-list">
33
<li *ngFor="let article of newsList" class="news-list-option">
4-
<a class="news-link" [href]="(navOptions['about']?.dropdownLinks?.['news']?.link || '/content/latest-news') + '/' + article.slug" >{{ formatD(article.date) }} - {{ article.title }}</a>
4+
<a class="news-link" [routerLink]="(navOptions['about']?.dropdownLinks?.['news']?.link || '/about/news') + '/' + article.slug" >{{ formatD(article.date) }} - {{ article.title }}</a>
55
</li>
66
</ul>

projects/website-angular/src/app/home-page/home-latest-news/home-latest-news.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, inject, Input, OnInit } from '@angular/core';
22
import { ArticleIndexItem } from '../../../types/article';
33
import { NgForOf, NgFor } from '@angular/common';
4+
import { RouterModule } from '@angular/router';
45
import formatDate from '../../../utils/formatDate';
56
import { ContentService } from '../../../services/content.service';
67
import { mapNavOptions } from '../../../utils/nav-options-mapper';
@@ -9,7 +10,7 @@ import { NavOption } from '../../../types/link';
910
@Component({
1011
selector: 'app-home-latest-news',
1112
standalone: true,
12-
imports: [NgForOf, NgFor],
13+
imports: [NgForOf, NgFor, RouterModule],
1314
templateUrl: './home-latest-news.component.html',
1415
styleUrl: './home-latest-news.component.scss'
1516
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1 class="home-spotlight-title">Reactome Research Spotlight</h1>
22
<span class="home-spotlight-text">{{ "[" + formatD(spotLightArticle.date) + "] " + spotLightArticle.title}}</span>
33
<p class="home-spotlight-text" [innerHTML]="renderedContent"></p>
4-
<a [href]="(navOptions['content']?.dropdownLinks?.['reactome-research-spotlight']?.link || '/content/reactome-research-spotlight') + '/' + spotLightArticle.slug" class="home-spotlight-link">
4+
<a [routerLink]="(navOptions['content']?.dropdownLinks?.['reactome-research-spotlight']?.link || '/content/reactome-research-spotlight') + '/' + spotLightArticle.slug" class="home-spotlight-link">
55
<app-button style="width: fit-content; height: min-content; padding: 16px;">Learn More</app-button>
66
</a>

projects/website-angular/src/app/home-page/home-spotlight/home-spotlight.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, inject, Input } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
23
import { ButtonComponent } from "../../reactome-components/button/button.component";
34
import { mapNavOptions } from '../../../utils/nav-options-mapper';
45
import { ArticleIndexItem } from '../../../types/article';
@@ -12,7 +13,7 @@ import { NavOption } from '../../../types/link';
1213
@Component({
1314
selector: 'app-home-spotlight',
1415
standalone: true,
15-
imports: [ButtonComponent],
16+
imports: [RouterModule, ButtonComponent],
1617
templateUrl: './home-spotlight.component.html',
1718
styleUrl: './home-spotlight.component.scss'
1819
})

projects/website-angular/src/app/navigation-bar/navigation-bar.component.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<header class="navbar-header">
22
<div class="navbar-logo">
3-
<a href="/" class="logo-link">
3+
<a routerLink="/" class="logo-link">
44
<img
55
src="assets/logo/logo.png"
66
alt="Reactome Pathway Database"
@@ -23,6 +23,28 @@
2323
<ng-container *ngIf="asNavOption(option.value) as navOption">
2424
<div class="nav-link-wrapper">
2525
<a
26+
*ngIf="!navOption.external"
27+
[routerLink]="(windowWidth > 768 || navOption.label == 'Download') ? navOption.link : null"
28+
class="nav-link"
29+
[class.has-dropdown]="
30+
navOption.dropdownLinks && (navOption.dropdownLinks | keyvalue:preserveOrder).length > 0
31+
"
32+
>
33+
<mat-icon>
34+
{{ navOption.icon }}
35+
</mat-icon>
36+
{{ navOption.label }}
37+
<mat-icon
38+
*ngIf="
39+
navOption.dropdownLinks && (navOption.dropdownLinks | keyvalue:preserveOrder).length > 0
40+
"
41+
class="dropdown-arrow"
42+
>
43+
keyboard_arrow_down
44+
</mat-icon>
45+
</a>
46+
<a
47+
*ngIf="navOption.external"
2648
[attr.href]="(windowWidth > 768 || navOption.label == 'Download') ? navOption.link : null"
2749
class="nav-link"
2850
[class.has-dropdown]="
@@ -80,6 +102,15 @@
80102
"
81103
>
82104
<a
105+
*ngIf="!navLink.external"
106+
[routerLink]="navLink.link"
107+
class="dropdown-link"
108+
[class.nested-dropdown-link]="level > 0"
109+
>
110+
{{ navLink.label }}
111+
</a>
112+
<a
113+
*ngIf="navLink.external"
83114
[href]="navLink.link"
84115
class="dropdown-link"
85116
[class.nested-dropdown-link]="level > 0"

projects/website-angular/src/app/navigation-bar/navigation-bar.component.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,36 @@ export class NavigationBarComponent implements OnInit, AfterViewInit {
4343
}
4444

4545
loadNavOptions() {
46-
// Load nav options from the JSON file
47-
import('../../config/nav-options.json').then((data) => {
48-
this.navOptions = mapNavOptions(data.default);
46+
Promise.all([
47+
import('../../config/nav-options.json'),
48+
import('../../config/config.json')
49+
]).then(([navData, configData]) => {
50+
this.navOptions = mapNavOptions(navData.default);
51+
this.resolveExternalLinks(configData.default.baseUrl);
4952
});
5053
}
5154

55+
/**
56+
* Prepend baseUrl to external links so they resolve to the correct domain
57+
*/
58+
private resolveExternalLinks(baseUrl: string) {
59+
const resolve = (links: Record<string, NavLink> | undefined) => {
60+
if (!links) return;
61+
for (const link of Object.values(links)) {
62+
if (link.external) {
63+
link.link = baseUrl + link.link;
64+
}
65+
resolve(link.dropdownLinks);
66+
}
67+
};
68+
for (const option of Object.values(this.navOptions)) {
69+
if (option.external) {
70+
option.link = baseUrl + option.link;
71+
}
72+
resolve(option.dropdownLinks);
73+
}
74+
}
75+
5276
toggleHamburgerMenu() {
5377
this.activeHamburgerMenu = !this.activeHamburgerMenu;
5478
}

projects/website-angular/src/config/nav-options.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,13 @@
279279
},
280280
"analysis-service": {
281281
"label": "Analysis Service",
282-
"link": "/AnalysisService"
282+
"link": "/AnalysisService",
283+
"external": true
283284
},
284285
"content-service": {
285286
"label": "Content Service",
286-
"link": "/ContentService"
287+
"link": "/ContentService",
288+
"external": true
287289
},
288290
"reactome-fiviz": {
289291
"label": "ReactomeFIViz",

projects/website-angular/src/services/stats.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ export class StatsService {
6464
return of(defaultStats);
6565
}
6666

67-
// In the browser, use the /reactome proxy path to avoid CORS.
68-
// In SSR (server.ts), requests to /reactome/* are proxied server-side.
69-
const baseUrl = this.isBrowser ? '/reactome' : await this.getDownloadBaseUrl();
67+
const baseUrl = await this.getDownloadBaseUrl();
7068
const version = await this.getVersion();
7169

7270
const url = `${baseUrl}/${version}/stats/summary_stats.json`;

projects/website-angular/src/types/link.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface ExternalLink {
44
}
55

66
export interface NavLink extends ExternalLink {
7+
external?: boolean;
78
dropdownLinks?: Record<string, NavLink>;
89
}
910

0 commit comments

Comments
 (0)