Skip to content

Commit

Permalink
add us wellness navlink (#26661)
Browse files Browse the repository at this point in the history
  • Loading branch information
cemms1 authored Nov 1, 2023
1 parent f83bbeb commit 9bf3c85
Show file tree
Hide file tree
Showing 3 changed files with 3,217 additions and 3,204 deletions.
4 changes: 3 additions & 1 deletion common/app/navigation/NavLinks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ object NavLinks {
val ukTravel = NavLink("Travel", "/travel", children = List(travelUk, travelEurope, travelUs))
val usTravel = ukTravel.copy(children = List(travelUs, travelEurope, travelUk))
val auTravel = ukTravel.copy(children = List(travelAustralasia, travelAsia, travelUk, travelEurope, travelUs))
val usWellness = NavLink("Wellness", "/us/wellness")

val todaysPaper = NavLink(
"Today's paper",
Expand Down Expand Up @@ -304,7 +305,7 @@ object NavLinks {
tech,
science,
newsletters.copy(url = s"${newsletters.url}"),
fightForDemocracy,
usWellness,
),
)
val intNewsPillar = ukNewsPillar.copy(
Expand Down Expand Up @@ -512,6 +513,7 @@ object NavLinks {
)
val usLifestylePillar = ukLifestylePillar.copy(
children = List(
usWellness,
fashion,
food,
recipes,
Expand Down
16 changes: 11 additions & 5 deletions common/app/navigation/Navigation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,19 @@ object NavMenu {
pillars: Seq[NavLink],
otherLinks: Seq[NavLink],
): Option[NavLink] = {
// Football is currently in the News Pillar and the Sport pillar, however we don't want the parent to be News.
def isFootballInNews(parentTitle: String): Boolean = {
currentNavLink.title == "Football" && parentTitle == "News"

// When nav items can appear in two pillars, we want to ignore the least relevant one
def shouldIgnoreParent(parentTitle: String): Boolean = {
// Football is currently in the News Pillar and the Sport pillar, however we don't want the parent to be News.
(currentNavLink.title == "Football" && parentTitle == "News") ||
// Wellness is in both the News Pillar and the Lifestyle pillar, however we don't want the parent to be News.
(currentNavLink.title == "Wellness" && parentTitle == "News")
}

def isParent(link: NavLink): Boolean =
link == currentNavLink || link.children.contains(currentNavLink) && !isFootballInNews(link.title)
def isParent(link: NavLink): Boolean = {
link == currentNavLink ||
link.children.contains(currentNavLink) && !shouldIgnoreParent(link.title)
}

find(pillars ++ otherLinks, isParent)
.orElse(find(getChildrenFromOtherEditions(edition), isParent))
Expand Down
Loading

0 comments on commit 9bf3c85

Please sign in to comment.