-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #521 from GeotrekCE/develop
Develop > Master / 3.5.1
- Loading branch information
Showing
15 changed files
with
136 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
[] | ||
[ | ||
{ | ||
"id": "cities", | ||
"display": false | ||
}, | ||
{ | ||
"id": "structures", | ||
"display": false | ||
}, | ||
{ | ||
"id": "difficulty", | ||
"display": false | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,42 @@ | ||
import getNextConfig from 'next/config'; | ||
import { FooterConfig } from './interface'; | ||
import { useRouter } from 'next/router'; | ||
import { useQuery } from 'react-query'; | ||
import { getFlatPages } from 'modules/flatpage/connector'; | ||
import { MenuItem } from 'modules/header/interface'; | ||
import { getDefaultLanguage } from 'modules/header/utills'; | ||
import { FooterConfigInput, FooterConfigOutput, PortalLinkStatic } from './interface'; | ||
|
||
const getFooterConfig = (): FooterConfig => { | ||
const getFooterConfig = (): FooterConfigInput => { | ||
const { | ||
publicRuntimeConfig: { footer }, | ||
} = getNextConfig(); | ||
|
||
return footer; | ||
}; | ||
|
||
export const useFooter = (): { config: FooterConfig } => { | ||
const config = getFooterConfig(); | ||
return { config }; | ||
export const useFooter = (): { config: FooterConfigOutput } => { | ||
const { links, ...rest } = getFooterConfig(); | ||
let nextLinks; | ||
// If the footer config contains `informationID` keys,the app retrieves "flatpages" to get the corresponding label/url | ||
if (links && links.some(link => 'informationID' in link)) { | ||
const language = useRouter().locale ?? getDefaultLanguage(); | ||
const { data } = useQuery<MenuItem[], Error>(['header', language], () => | ||
getFlatPages(language), | ||
); | ||
nextLinks = links | ||
.map(link => { | ||
if ('informationID' in link) { | ||
const page = data?.find(({ id }) => id === link.informationID); | ||
if (page) { | ||
return { label: page.title, url: page.url }; | ||
} | ||
return null; | ||
} | ||
return link; | ||
}) | ||
// If the informationID doesn't match with any flatPage id, it won't be displayed | ||
.filter(Boolean) as PortalLinkStatic[]; | ||
} | ||
|
||
return { config: { links: nextLinks ?? (links as PortalLinkStatic[]), ...rest } }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
export const isLinkInternal = (urlString: string): boolean => { | ||
if (typeof window !== 'undefined') { | ||
const url = new URL(urlString); | ||
return url.hostname === window.location.hostname; | ||
} | ||
return false; | ||
const { hostname } = new URL(urlString, document.baseURI); | ||
return hostname === global.location.hostname; | ||
}; | ||
|
||
export const linkWithoutHost = (urlString: string): string => { | ||
const url = new URL(urlString); | ||
return url.pathname; | ||
const { pathname } = new URL(urlString, document.baseURI); | ||
return pathname; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters