Merged in feat/refactor-header-footer-sitewidealert (pull request #1374)
Refactor: removed parallel routes for header, footer and sidewidealert. Langswitcher and sidewidealert now client components * feat - removed parallel routes and made sidepeek and sitewidealerts as client components * Langswitcher as client component * Fixed lang switcher for current header * Passing lang when fetching siteconfig * Merge branch 'master' into feat/refactor-header-footer-sitewidealert * Refactor * Removed dead code * Show only languages that has translation * Refetch sitewidealert every 60 seconds * Merge branch 'master' into feat/refactor-header-footer-sitewidealert * Removed sidepeek parallel route from my-stay * Added missing env.var to env.test * Removed console.log Approved-by: Joakim Jäderberg
This commit is contained in:
21
services/cms/getUidAndContentTypeByPath.ts
Normal file
21
services/cms/getUidAndContentTypeByPath.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
import { findLang } from "@/utils/languages"
|
||||
import { removeTrailingSlash } from "@/utils/url"
|
||||
|
||||
import { fetchAndCacheEntry } from "./fetchAndCacheEntry"
|
||||
|
||||
export const getUidAndContentTypeByPath = async (pathname: string) => {
|
||||
const lang = findLang(pathname)
|
||||
|
||||
const pathWithoutTrailingSlash = removeTrailingSlash(pathname)
|
||||
|
||||
const contentTypePathName = pathWithoutTrailingSlash.replace(`/${lang}`, "")
|
||||
|
||||
const { contentType, uid } = await fetchAndCacheEntry(
|
||||
contentTypePathName,
|
||||
lang ?? Lang.en
|
||||
)
|
||||
|
||||
return { contentType, uid }
|
||||
}
|
||||
Reference in New Issue
Block a user