Merged in feat/SW-1296-hotel-subpages (pull request #1233)

feat(SW-1296): added Subpage for hotel pages and its routing

* feat(SW-1296): added Subpage for hotel pages and its routing


Approved-by: Fredrik Thorsson
This commit is contained in:
Erik Tiekstra
2025-02-03 10:58:53 +00:00
parent b2a3fca54a
commit dd4a2d8120
9 changed files with 252 additions and 24 deletions

View File

@@ -29,6 +29,7 @@ export default function Link({
* Decides if the link should include the current search params in the URL
*/
keepSearchParams,
appendToCurrentPath,
...props
}: LinkProps) {
const currentPageSlug = usePathname()
@@ -50,11 +51,24 @@ export default function Link({
})
const fullUrl = useMemo(() => {
if (!keepSearchParams || !searchParams.size) return href
let newPath = href
if (appendToCurrentPath) {
newPath = `${currentPageSlug}${newPath}`
}
const delimiter = href.includes("?") ? "&" : "?"
return `${href}${delimiter}${searchParams}`
}, [href, searchParams, keepSearchParams])
if (keepSearchParams && searchParams.size) {
const delimiter = newPath.includes("?") ? "&" : "?"
return `${newPath}${delimiter}${searchParams}`
}
return newPath
}, [
href,
searchParams,
keepSearchParams,
appendToCurrentPath,
currentPageSlug,
])
// TODO: Remove this check (and hook) and only return <Link /> when current web is deleted
const isExternal = useCheckIfExternalLink(href)

View File

@@ -12,4 +12,5 @@ export interface LinkProps
trackingId?: string
trackingParams?: Record<string, string>
keepSearchParams?: boolean
appendToCurrentPath?: boolean
}