From 96857a42a69eb3a516858d62753193085409b795 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Sun, 29 Jun 2025 22:36:37 +0300 Subject: [PATCH 1/2] Update uninav - support octana navigation --- public/assets/logo.svg | 44 +++++++++- src/lib/components/LinksMenu.svelte | 17 +++- src/lib/components/SubMenu.svelte | 10 +++ src/lib/components/TcLogo.module.scss | 2 +- src/lib/components/TopNavbar.module.scss | 4 +- src/lib/config/hosts.ts | 2 +- .../config/nav-menu/all-nav-items.config.ts | 82 +++++++++++++------ src/lib/config/nav-menu/footer-nav-items.ts | 14 ++-- .../config/nav-menu/main-navigation.config.ts | 21 ++++- .../FooterNavigation.module.scss | 1 + .../footer-navigation/FooterNavigation.svelte | 4 +- .../marketing-navigation.provider.ts | 5 +- src/lib/functions/nav-menu-item.model.ts | 2 + .../MarketingNavigation.svelte | 12 +-- .../components/NavigationBar.svelte | 5 ++ src/lib/utils/location.store.ts | 21 +++++ src/lib/utils/paths.ts | 33 +++++++- src/lib/utils/routes.ts | 2 +- .../marketing-navigation.provider.d.ts | 2 +- .../lib/functions/nav-menu-item.model.d.ts | 1 + types/src/lib/utils/location.store.d.ts | 2 + 21 files changed, 225 insertions(+), 61 deletions(-) create mode 100644 src/lib/utils/location.store.ts create mode 100644 types/src/lib/utils/location.store.d.ts diff --git a/public/assets/logo.svg b/public/assets/logo.svg index 03edf122..54f628db 100644 --- a/public/assets/logo.svg +++ b/public/assets/logo.svg @@ -1 +1,43 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lib/components/LinksMenu.svelte b/src/lib/components/LinksMenu.svelte index dd4f642a..9ed85dfe 100644 --- a/src/lib/components/LinksMenu.svelte +++ b/src/lib/components/LinksMenu.svelte @@ -4,6 +4,7 @@ import { classnames } from "lib/utils/classnames"; import { getPublicPath } from 'lib/utils/paths'; import SubMenu from "./SubMenu.svelte"; + import { NavigationHandler } from "../app-context/navigation-handler.model"; const chevronDownIconUrl = getPublicPath(`/assets/ic-chevron-down.svg`); export let ref: Element | undefined = undefined; @@ -13,12 +14,13 @@ export let activeRoute: NavMenuItem = undefined; export let activeRoutePath: NavMenuItem[] = []; export let vertical: boolean = false; + export let navigationHandler: NavigationHandler | undefined = undefined; let hoveredMenuItem: NavMenuItem = undefined; let hoveredElement: HTMLElement = undefined; let isPopupMenuActive: boolean = false; - function isActiveMenu(menuItem: NavMenuItem) { - return activeRoute?.url !== undefined && menuItem.url === activeRoute?.url + function isActiveMenu(menuItem: NavMenuItem, activeMenuItem: NavMenuItem) { + return activeMenuItem?.url !== undefined && menuItem.url === activeMenuItem?.url } function itemHasHoverMenu(menuItem: NavMenuItem) { @@ -42,6 +44,13 @@ itemHasHoverMenu(menuItem) && 'has-menu', ) } + + function handleNavigation(ev: MouseEvent) { + if (typeof navigationHandler === 'function') { + ev.preventDefault() + navigationHandler({label: '', path: (ev.target as HTMLAnchorElement).href}); + } + }
@@ -50,13 +59,14 @@ diff --git a/src/lib/components/SubMenu.svelte b/src/lib/components/SubMenu.svelte index 68ffef69..db48c3b4 100644 --- a/src/lib/components/SubMenu.svelte +++ b/src/lib/components/SubMenu.svelte @@ -1,11 +1,13 @@ {#if menuItems?.length} @@ -32,6 +41,7 @@ class:active={activeRoute?.url === menuItem.url} target={menuItem.target ?? '_top'} href={menuItem.url} + on:click={handleNavigation} > {menuItem.label} diff --git a/src/lib/components/TcLogo.module.scss b/src/lib/components/TcLogo.module.scss index d0dab624..d359b35a 100644 --- a/src/lib/components/TcLogo.module.scss +++ b/src/lib/components/TcLogo.module.scss @@ -7,7 +7,7 @@ img { display: block; - height: 32px; + height: 64px; } .min { diff --git a/src/lib/components/TopNavbar.module.scss b/src/lib/components/TopNavbar.module.scss index e1ae1427..efb64b79 100644 --- a/src/lib/components/TopNavbar.module.scss +++ b/src/lib/components/TopNavbar.module.scss @@ -31,14 +31,14 @@ .topNavbarInner { @include maxViewWidth; - padding: 18px 32px; + padding: 16px 32px; display: flex; align-items: center; flex: 1 1 auto; margin: 0 auto; @include tablet { - padding: 18px 16px; + padding: 16px 16px; } @include mobile { diff --git a/src/lib/config/hosts.ts b/src/lib/config/hosts.ts index bbb5614d..b5facefc 100644 --- a/src/lib/config/hosts.ts +++ b/src/lib/config/hosts.ts @@ -12,7 +12,7 @@ export const TC_DOMAIN: string = { // export const WP_HOST_URL: string = `http://localhost:5173`; -export const WP_HOST_URL: string = `https://www.${TC_DOMAIN}`; +export const MARKETING_HOST_URL: string = `https://www.${TC_DOMAIN}`; export const CHALLENGE_HOST: string = `https://www.${TC_DOMAIN}`; export const COMMUNITY_HOST: string = `https://www.${TC_DOMAIN}`; diff --git a/src/lib/config/nav-menu/all-nav-items.config.ts b/src/lib/config/nav-menu/all-nav-items.config.ts index a6d37a9f..ffc2ba1b 100644 --- a/src/lib/config/nav-menu/all-nav-items.config.ts +++ b/src/lib/config/nav-menu/all-nav-items.config.ts @@ -1,4 +1,4 @@ -import { getWordpressUrl } from "../../utils/paths"; +import { getMarketingUrl } from "../../utils/paths"; import type { NavMenuItem } from "../../functions/nav-menu-item.model"; import { @@ -6,10 +6,8 @@ import { COMMUNITY_HOST, CONNECT_HOST, ONLINE_REVIEW_HOST, - SELF_SERVICE_HOST, TALENT_SEARCH_HOST, TCACADEMY_HOST, - THRIVE_HOST, PLATFORM_APP_HOST, WALLETAPP_HOST, WORK_MANAGER_HOST, @@ -19,54 +17,59 @@ import { export const allNavItems: {[key: string]: NavMenuItem} = { login: { label: 'Login', - url: `${AUTH0_AUTHENTICATOR_URL}?retUrl=${encodeURIComponent(getWordpressUrl('/home'))}` + url: `${AUTH0_AUTHENTICATOR_URL}?retUrl=${encodeURIComponent(getMarketingUrl('/home'))}` }, freelancer: { label: 'I\'m a Freelancer', - url: getWordpressUrl('/freelancer'), + marketingPathname: '/freelancer', + url: getMarketingUrl('/freelancer'), }, community: { label: 'Community', }, + solutions: { + label: 'Solutions', + }, + resources: { + label: 'Resources', + }, opportunities: { label: 'Opportunities', - url: getWordpressUrl('/challenges'), + url: `${CHALLENGE_HOST}/challenges`, }, mmTournament: { label: 'Marathon Match Tournament', icon: 'mm-tournament', description: 'Join the Excitement', - url: getWordpressUrl('/marathon-match-tournament'), + marketingPathname: '/marathon-match-tournament', + url: getMarketingUrl('/marathon-match-tournament'), }, aiHub: { label: 'AI Hub', icon: 'ai-hub', description: 'Collaborate, Compete, Create', - url: getWordpressUrl('/ai-hub'), + marketingPathname: '/ai-hub', + url: getMarketingUrl('/ai-hub'), }, howItWorks: { label: 'How it works', - url: getWordpressUrl('/how-it-works'), + marketingPathname: '/how-it-works', + url: getMarketingUrl('/how-it-works'), }, statistics: { label: 'Statistics', - url: getWordpressUrl('/community/statistics'), + marketingPathname: '/community/statistics', + url: getMarketingUrl('/community/statistics'), }, demo: { label: 'Demo', - url: getWordpressUrl('/customer/demo'), + marketingPathname: '/customer/demo', + url: getMarketingUrl('/customer/demo'), }, product: { label: 'Product', - url: getWordpressUrl('/customer/product'), - }, - customerStories: { - label: 'Customer Stories', - url: getWordpressUrl('/customer-stories'), - }, - talent: { - label: 'The Talent', - url: getWordpressUrl('/talent'), + marketingPathname: '/customer/product', + url: getMarketingUrl('/customer/product'), }, support: { label: 'Support', @@ -84,7 +87,8 @@ export const allNavItems: {[key: string]: NavMenuItem} = { label: 'Articles', icon: 'articles', description: 'Get insights and tips about Topcoder', - url: getWordpressUrl('/thrive'), + marketingPathname: '/thrive', + url: getMarketingUrl('/thrive'), }, bookADemo: { label: 'Book a Demo', @@ -106,7 +110,8 @@ export const allNavItems: {[key: string]: NavMenuItem} = { }, home: { label: 'Home', - url: getWordpressUrl(''), + marketingPathname: '/', + url: getMarketingUrl('/'), }, marathonMatchesApp: { label: 'Marathon Matches', @@ -136,7 +141,7 @@ export const allNavItems: {[key: string]: NavMenuItem} = { label: 'Community Home', description: 'Recent challenges and news.', icon: 'topcrowd', - url: getWordpressUrl('/home'), + url: `${COMMUNITY_HOST}/home`, }, talentSearchApp: { label: 'Meet our Talent', @@ -170,14 +175,37 @@ export const allNavItems: {[key: string]: NavMenuItem} = { }, bugHunt: { label: 'Bug Hunt', - url: getWordpressUrl('/customer/product/bughunt'), + marketingPathname: '/customer/product/bughunt', + url: getMarketingUrl('/customer/product/bughunt'), }, platform: { label: 'Platform', - url: getWordpressUrl('/customer/product'), + marketingPathname: '/customer/product', + url: getMarketingUrl('/customer/product'), }, innovationChallenges: { label: 'Innovation Challenges', - url: getWordpressUrl('/innovation-challenges'), - } + marketingPathname: '/innovation-challenges', + url: getMarketingUrl('/innovation-challenges'), + }, + tcSolutions: { + label: 'Topcoder Solutions', + marketingPathname: '/topcoder-solutions', + url: getMarketingUrl('/topcoder-solutions'), + }, + projectLifecycle: { + label: 'Project Lifecycle', + marketingPathname: '/project-lifecycle', + url: getMarketingUrl('/project-lifecycle'), + }, + customerStories: { + label: 'Customer Stories', + marketingPathname: '/customer-stories', + url: getMarketingUrl('/customer-stories'), + }, + talent: { + label: 'The Talent', + marketingPathname: '/talent', + url: getMarketingUrl('/talent'), + }, } diff --git a/src/lib/config/nav-menu/footer-nav-items.ts b/src/lib/config/nav-menu/footer-nav-items.ts index f17f1733..680fa588 100644 --- a/src/lib/config/nav-menu/footer-nav-items.ts +++ b/src/lib/config/nav-menu/footer-nav-items.ts @@ -1,4 +1,4 @@ -import { getWordpressUrl } from "lib/utils/paths"; +import { getMarketingUrl } from "lib/utils/paths"; import type { NavMenuItem } from "../../functions/nav-menu-item.model"; import { allNavItems } from "./all-nav-items.config"; @@ -10,15 +10,15 @@ export const footerNavItems: NavMenuItem = { children: [ { label: 'How it Works', - url: getWordpressUrl('/how-it-works'), + url: getMarketingUrl('/how-it-works'), }, { label: 'The Talent', - url: getWordpressUrl('/talent'), + url: getMarketingUrl('/talent'), }, { label: 'Customer Stories', - url: getWordpressUrl('/customer-stories'), + url: getMarketingUrl('/customer-stories'), }, ] }, @@ -27,7 +27,7 @@ export const footerNavItems: NavMenuItem = { children: [ { label: 'I\'m a Freelancer', - url: getWordpressUrl('/freelancer'), + url: getMarketingUrl('/freelancer'), }, allNavItems.opportunities, allNavItems.mmTournament, @@ -42,11 +42,11 @@ export const footerNavItems: NavMenuItem = { allNavItems.support, { label: 'Terms and Conditions', - url: getWordpressUrl('/community/how-it-works/terms') + url: getMarketingUrl('/community/how-it-works/terms') }, { label: 'Privacy Policy', - url: getWordpressUrl('/privacy') + url: getMarketingUrl('/privacy') }, ] }, diff --git a/src/lib/config/nav-menu/main-navigation.config.ts b/src/lib/config/nav-menu/main-navigation.config.ts index 001b6f15..1a4b80de 100644 --- a/src/lib/config/nav-menu/main-navigation.config.ts +++ b/src/lib/config/nav-menu/main-navigation.config.ts @@ -4,17 +4,30 @@ import { allNavItems } from "./all-nav-items.config"; export const mainNavigationItems: NavMenuItem[] = [ allNavItems.howItWorks, - allNavItems.talent, - allNavItems.customerStories, - allNavItems.freelancer, + { + ...allNavItems.solutions, + children: [ + allNavItems.tcSolutions, + allNavItems.projectLifecycle, + allNavItems.customerStories, + allNavItems.talent, + ], + }, { ...allNavItems.community, children: [ + allNavItems.freelancer, allNavItems.opportunities, allNavItems.mmTournament, allNavItems.aiHub, - allNavItems.articles, allNavItems.statistics, ] }, + { + ...allNavItems.resources, + children: [ + // allNavItems.blog, + allNavItems.articles, + ], + }, ] diff --git a/src/lib/footer-navigation/FooterNavigation.module.scss b/src/lib/footer-navigation/FooterNavigation.module.scss index d190aa88..177a3cc9 100644 --- a/src/lib/footer-navigation/FooterNavigation.module.scss +++ b/src/lib/footer-navigation/FooterNavigation.module.scss @@ -44,6 +44,7 @@ margin-top: 0; margin-bottom: 16px; font-family: $nunito; + color: inherit; } p { diff --git a/src/lib/footer-navigation/FooterNavigation.svelte b/src/lib/footer-navigation/FooterNavigation.svelte index 3fb7a42f..f8f607e2 100644 --- a/src/lib/footer-navigation/FooterNavigation.svelte +++ b/src/lib/footer-navigation/FooterNavigation.svelte @@ -6,7 +6,7 @@ import { handleNavItemAction } from 'lib/utils/nav-item-action.handler'; import type { NavMenuItem } from 'lib/functions/nav-menu-item.model'; import styles from './FooterNavigation.module.scss' - import { getPublicPath, getWordpressUrl } from 'lib/utils/paths'; + import { getPublicPath, getMarketingUrl } from 'lib/utils/paths'; import SocialIcon from './SocialIcon.svelte'; $: logoUrl = getPublicPath(`/assets/inverted-logo.svg`); @@ -45,7 +45,7 @@
{/if} {#if i === 2} - + Talk to an expert
diff --git a/src/lib/functions/marketing-navigation.provider.ts b/src/lib/functions/marketing-navigation.provider.ts index 0b9ae8de..5bcddd81 100644 --- a/src/lib/functions/marketing-navigation.provider.ts +++ b/src/lib/functions/marketing-navigation.provider.ts @@ -1,15 +1,16 @@ import { marketingNavItems } from 'lib/config/nav-menu/marketing-nav-items'; import { getActiveRoute as getActiveRouteUtil, activateAuthenticatedRoutes } from 'lib/utils/routes' import type { NavMenuItem } from './nav-menu-item.model'; +import { toMarketingHostUrls } from 'lib/utils/paths'; const navMenu = marketingNavItems as unknown as NavMenuItem export function getMainNavItems(isAuthenticated: boolean): NavMenuItem[] { const menu = JSON.parse(JSON.stringify(navMenu)); - return activateAuthenticatedRoutes(isAuthenticated, menu); + return toMarketingHostUrls({children: activateAuthenticatedRoutes(isAuthenticated, menu)}); } -export function getActiveRoute(navItems: NavMenuItem[], index?: number): NavMenuItem[] { +export function getActiveRoute(navItems: NavMenuItem[], index?: number, deps?: any): NavMenuItem[] { return getActiveRouteUtil(navItems, index); } diff --git a/src/lib/functions/nav-menu-item.model.ts b/src/lib/functions/nav-menu-item.model.ts index bff6de8f..f22f8941 100644 --- a/src/lib/functions/nav-menu-item.model.ts +++ b/src/lib/functions/nav-menu-item.model.ts @@ -13,6 +13,8 @@ export interface NavMenuItem { icon?: string label?: string type?: 'cta' + marketingPathname?: string; + pathname?: string url?: string target?: string uiAttr?: string // allow to pass class names for ui alterations diff --git a/src/lib/marketing-navigation/MarketingNavigation.svelte b/src/lib/marketing-navigation/MarketingNavigation.svelte index 3a4e2cfd..103d8c78 100644 --- a/src/lib/marketing-navigation/MarketingNavigation.svelte +++ b/src/lib/marketing-navigation/MarketingNavigation.svelte @@ -8,21 +8,22 @@ import type { NavMenuItem } from 'lib/functions/nav-menu-item.model'; import { getActiveRoute, getMainNavItems } from 'lib/functions/marketing-navigation.provider' import { isMobile } from 'lib/utils/window-size.store'; + import { windowLocation } from 'lib/utils/location.store'; import { checkAndLoadFonts } from 'lib/utils/fonts'; import NavigationBar from './components/NavigationBar.svelte'; - import Banner from 'lib/components/Banner.svelte'; const ctx = getAppContext() - $: ({auth} = $ctx) + $: ({auth, navigationHandler} = $ctx) let isAuthenticated: boolean; $: isAuthenticated = auth.ready && !!auth.user; + export let customMenuItems: NavMenuItem[]; let menuItems: NavMenuItem[]; - $: menuItems = getMainNavItems(isAuthenticated) + $: menuItems = customMenuItems ?? getMainNavItems(isAuthenticated) let activeRoute: NavMenuItem[] = []; - $: activeRoute = getActiveRoute(menuItems) + $: activeRoute = getActiveRoute(menuItems, 0, $windowLocation) let primaryRoute: NavMenuItem; let secondaryRoute: NavMenuItem; @@ -32,12 +33,13 @@
- +
diff --git a/src/lib/marketing-navigation/components/NavigationBar.svelte b/src/lib/marketing-navigation/components/NavigationBar.svelte index 4840c791..daaf36b2 100644 --- a/src/lib/marketing-navigation/components/NavigationBar.svelte +++ b/src/lib/marketing-navigation/components/NavigationBar.svelte @@ -5,12 +5,14 @@ import MobileNavigation from 'lib/mobile-navigation/MobileNavigation.svelte'; import { marketingRightItems } from 'lib/functions/marketing-navigation.provider' import { allNavItems } from 'lib/config/nav-menu/all-nav-items.config'; + import { NavigationHandler } from "../../app-context/navigation-handler.model"; export let style: 'primary'|'secondary'|'tertiary'; export let menuItems: NavMenuItem[] = []; export let activeRoutePath: NavMenuItem[] = []; export let activeRoute: NavMenuItem; export let isMobile: boolean = false; + export let navigationHandler: NavigationHandler | undefined; @@ -26,6 +28,7 @@ style={style} activeRoute={activeRoute} activeRoutePath={activeRoutePath} + navigationHandler={navigationHandler} /> {/if} @@ -36,6 +39,7 @@ style={style} activeRoute={activeRoute} activeRoutePath={activeRoutePath} + navigationHandler={navigationHandler} /> {:else} {/if} diff --git a/src/lib/utils/location.store.ts b/src/lib/utils/location.store.ts new file mode 100644 index 00000000..b8ee59e3 --- /dev/null +++ b/src/lib/utils/location.store.ts @@ -0,0 +1,21 @@ +import { derived, readable } from "svelte/store"; + +window.history.pushState = new Proxy(window.history.pushState, { + apply: (target, thisArg, argArray) => { + const r = target.apply(thisArg, argArray); + window.dispatchEvent(new Event('pushstate')); + return r; + }, +}); + +export const windowLocation = readable({} as Location, (set) => { + const updateLocation = () => { + set(window.location); + }; + + window.addEventListener('pushstate', updateLocation); + updateLocation(); + return () => window.removeEventListener('pushstate', updateLocation); +}); + +export const pathname = derived(windowLocation, ({pathname}) => pathname); diff --git a/src/lib/utils/paths.ts b/src/lib/utils/paths.ts index f02c1a29..4bf97613 100644 --- a/src/lib/utils/paths.ts +++ b/src/lib/utils/paths.ts @@ -1,5 +1,6 @@ -import { WP_HOST_URL } from '../config' +import { MARKETING_HOST_URL } from '../config' import * as pkg from '../../../package.json' +import { NavMenuItem } from 'lib/functions/nav-menu-item.model' const isProdBuild: boolean = typeof BUILD_IS_PROD !== 'undefined' ? BUILD_IS_PROD : true @@ -22,12 +23,36 @@ export function getPublicPath(assetPath: string): string { * @params path * @returns string */ -export function getWordpressUrl(path: string): string { - +export function getMarketingUrl(path: string): string { const locationPathname = typeof window === 'undefined' ? '' : window.location.pathname; // if the current host is a staging site, go to the staging site const pathPrefix: string = ['staging', 'universal-naviga'] .find(prefix => locationPathname.match(new RegExp(`\/${prefix}(\/|\\?|$)`))) - return `${WP_HOST_URL}${!!pathPrefix ? `/${pathPrefix}` : ''}${path}` + return `${MARKETING_HOST_URL}${!!pathPrefix ? `/${pathPrefix}` : ''}${path}` +} + +/** + * Parses the passed nav menu items and + * based on the `isAuthenticated` param + * activates the `authenticatedPath` for a nav menu item + * @param isAuthenticated + * @param navigationItem + * @returns NavMenuItem.children + */ +export const toMarketingHostUrls = ({ children = [] }: NavMenuItem, depth?: number) => { + // safe escape if things get out of control + if (depth >= 9) { + return + } + + for (let child of children) { + if (child.marketingPathname) { + child.url = child.marketingPathname; + } + + toMarketingHostUrls(child, depth + 1); + } + + return children; } diff --git a/src/lib/utils/routes.ts b/src/lib/utils/routes.ts index def9e8c1..7f32c995 100644 --- a/src/lib/utils/routes.ts +++ b/src/lib/utils/routes.ts @@ -6,7 +6,7 @@ export const routeMatchesUrl = (url: string, route: NavMenuItem): boolean => { return false; } - const urlObj = new URL(route.url); + const urlObj = new URL(route.url, location.origin); const routeUrl = `${urlObj.origin}${urlObj.pathname}`; return !!url.match(new RegExp(`^${escapeRegExp(routeUrl)}\/?(\\?|#|$)`, 'i')); diff --git a/types/src/lib/functions/marketing-navigation.provider.d.ts b/types/src/lib/functions/marketing-navigation.provider.d.ts index 11b96c3c..39ca1a0c 100644 --- a/types/src/lib/functions/marketing-navigation.provider.d.ts +++ b/types/src/lib/functions/marketing-navigation.provider.d.ts @@ -1,4 +1,4 @@ import type { NavMenuItem } from './nav-menu-item.model'; export declare function getMainNavItems(isAuthenticated: boolean): NavMenuItem[]; -export declare function getActiveRoute(navItems: NavMenuItem[], index?: number): NavMenuItem[]; +export declare function getActiveRoute(navItems: NavMenuItem[], index?: number, deps?: any): NavMenuItem[]; export { marketingRightItems } from 'lib/config/nav-menu/marketing-nav-items'; diff --git a/types/src/lib/functions/nav-menu-item.model.d.ts b/types/src/lib/functions/nav-menu-item.model.d.ts index 7f479e1e..fac738b9 100644 --- a/types/src/lib/functions/nav-menu-item.model.d.ts +++ b/types/src/lib/functions/nav-menu-item.model.d.ts @@ -11,6 +11,7 @@ export interface NavMenuItem { icon?: string; label?: string; type?: 'cta'; + pathname?: string; url?: string; target?: string; uiAttr?: string; diff --git a/types/src/lib/utils/location.store.d.ts b/types/src/lib/utils/location.store.d.ts new file mode 100644 index 00000000..f03b8dd9 --- /dev/null +++ b/types/src/lib/utils/location.store.d.ts @@ -0,0 +1,2 @@ +export declare const windowLocation: import("svelte/store").Readable; +export declare const pathname: import("svelte/store").Readable; From 0e0db919a7335c58e6d254a3e0186d8cac4f43b7 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Sun, 29 Jun 2025 22:37:37 +0300 Subject: [PATCH 2/2] types --- src/lib/utils/paths.ts | 2 +- types/src/lib/config/hosts.d.ts | 2 +- types/src/lib/functions/nav-menu-item.model.d.ts | 1 + types/src/lib/utils/paths.d.ts | 12 +++++++++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib/utils/paths.ts b/src/lib/utils/paths.ts index 4bf97613..4e2b15f7 100644 --- a/src/lib/utils/paths.ts +++ b/src/lib/utils/paths.ts @@ -1,6 +1,6 @@ import { MARKETING_HOST_URL } from '../config' import * as pkg from '../../../package.json' -import { NavMenuItem } from 'lib/functions/nav-menu-item.model' +import type { NavMenuItem } from 'lib/functions/nav-menu-item.model' const isProdBuild: boolean = typeof BUILD_IS_PROD !== 'undefined' ? BUILD_IS_PROD : true diff --git a/types/src/lib/config/hosts.d.ts b/types/src/lib/config/hosts.d.ts index 2b096bcd..2f60eae9 100644 --- a/types/src/lib/config/hosts.d.ts +++ b/types/src/lib/config/hosts.d.ts @@ -1,7 +1,7 @@ export declare type HOST_ENV_TYPE = 'dev' | 'prod' | 'qa'; export declare const HOST_ENV: HOST_ENV_TYPE; export declare const TC_DOMAIN: string; -export declare const WP_HOST_URL: string; +export declare const MARKETING_HOST_URL: string; export declare const CHALLENGE_HOST: string; export declare const COMMUNITY_HOST: string; export declare const THRIVE_HOST: string; diff --git a/types/src/lib/functions/nav-menu-item.model.d.ts b/types/src/lib/functions/nav-menu-item.model.d.ts index fac738b9..0155f0f6 100644 --- a/types/src/lib/functions/nav-menu-item.model.d.ts +++ b/types/src/lib/functions/nav-menu-item.model.d.ts @@ -11,6 +11,7 @@ export interface NavMenuItem { icon?: string; label?: string; type?: 'cta'; + marketingPathname?: string; pathname?: string; url?: string; target?: string; diff --git a/types/src/lib/utils/paths.d.ts b/types/src/lib/utils/paths.d.ts index daa27606..f3947ba9 100644 --- a/types/src/lib/utils/paths.d.ts +++ b/types/src/lib/utils/paths.d.ts @@ -1,3 +1,4 @@ +import type { NavMenuItem } from 'lib/functions/nav-menu-item.model'; /** * Gets the absolute path hosted on the same domain as the main script is * @param assetPath The relative path of the asset @@ -9,4 +10,13 @@ export declare function getPublicPath(assetPath: string): string; * @params path * @returns string */ -export declare function getWordpressUrl(path: string): string; +export declare function getMarketingUrl(path: string): string; +/** + * Parses the passed nav menu items and + * based on the `isAuthenticated` param + * activates the `authenticatedPath` for a nav menu item + * @param isAuthenticated + * @param navigationItem + * @returns NavMenuItem.children + */ +export declare const toMarketingHostUrls: ({ children }: NavMenuItem, depth?: number) => NavMenuItem[];