fix: get locale from page connection
This commit is contained in:
@@ -67,8 +67,9 @@ function ListItem({ listItem }: { listItem: ListItem }) {
|
|||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
case BlockListItemsEnum.CurrentBlocksPageBlocksListBlockListItemsListItemInternalLink:
|
case BlockListItemsEnum.CurrentBlocksPageBlocksListBlockListItemsListItemInternalLink:
|
||||||
const links = listItem.list_item_internal_link.pageConnection.edges
|
const link = listItem.list_item_internal_link.pageConnection.edges[0]
|
||||||
return links.map((link, i) => (
|
const linkUrlWithLocale= `/${link.node.system.locale}${link.node.url}`
|
||||||
|
return (
|
||||||
<li
|
<li
|
||||||
key={link.node.system.uid}
|
key={link.node.system.uid}
|
||||||
className={` ${
|
className={` ${
|
||||||
@@ -79,13 +80,13 @@ function ListItem({ listItem }: { listItem: ListItem }) {
|
|||||||
${styles.listItem}
|
${styles.listItem}
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<Link href={link.node.url} className={styles.link}>
|
<Link href={linkUrlWithLocale} className={styles.link}>
|
||||||
{listItem.list_item_internal_link.link_text}
|
{listItem.list_item_internal_link.link_text}
|
||||||
</Link>
|
</Link>
|
||||||
<br />
|
<br />
|
||||||
<span>{listItem.list_item_internal_link.subtitle}</span>
|
<span>{listItem.list_item_internal_link.subtitle}</span>
|
||||||
</li>
|
</li>
|
||||||
))
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
fragment CurrentBlocksPageLink on CurrentBlocksPage {
|
fragment CurrentBlocksPageLink on CurrentBlocksPage {
|
||||||
system {
|
system {
|
||||||
uid
|
uid
|
||||||
|
locale
|
||||||
}
|
}
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
@@ -9,7 +10,8 @@ fragment CurrentBlocksPageLink on CurrentBlocksPage {
|
|||||||
fragment TempPageLink on TempPage {
|
fragment TempPageLink on TempPage {
|
||||||
system {
|
system {
|
||||||
uid
|
uid
|
||||||
|
locale
|
||||||
}
|
}
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { Edges } from "../utils/edges"
|
import type { Edges } from "../utils/edges"
|
||||||
import type { ExternalLink } from "../utils/externalLink"
|
import type { TempPageLink } from "../utils/tempPageLink"
|
||||||
import type { PageLink } from "../utils/pageLink"
|
import type { PageLink } from "../utils/pageLink"
|
||||||
import { Typename } from "../utils/typename"
|
import { Typename } from "../utils/typename"
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ type InternalLinkListItem = Typename<
|
|||||||
link_text?: string
|
link_text?: string
|
||||||
list_item_style: ListItemStyle
|
list_item_style: ListItemStyle
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
pageConnection: Edges<ExternalLink | PageLink>
|
pageConnection: Edges<TempPageLink | PageLink>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
BlockListItemsEnum.CurrentBlocksPageBlocksListBlockListItemsListItemInternalLink
|
BlockListItemsEnum.CurrentBlocksPageBlocksListBlockListItemsListItemInternalLink
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import type { SysAsset } from "./utils/asset"
|
import type { SysAsset } from "./utils/asset"
|
||||||
import type { ExternalLinkType } from "./utils/externalLink"
|
import type { TempPageLinkType } from "./utils/tempPageLink"
|
||||||
import type { PageLinkType } from "./utils/pageLink"
|
import type { PageLinkType } from "./utils/pageLink"
|
||||||
|
|
||||||
export type Embeds =
|
export type Embeds = TempPageLinkType | PageLinkType | SysAsset
|
||||||
| ExternalLinkType
|
|
||||||
| PageLinkType
|
|
||||||
| SysAsset
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Image } from "../image"
|
import type { Image } from "../image"
|
||||||
import type { Edges } from "./utils/edges"
|
import type { Edges } from "./utils/edges"
|
||||||
import type { Embeds } from "./embeds"
|
import type { Embeds } from "./embeds"
|
||||||
import type { ExternalLink } from "./utils/externalLink"
|
import type { TempPageLink } from "./utils/tempPageLink"
|
||||||
import type { PageLink } from "./utils/pageLink"
|
import type { PageLink } from "./utils/pageLink"
|
||||||
import type { RTEDocument } from "../rte/node"
|
import type { RTEDocument } from "../rte/node"
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ export type Puff = {
|
|||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
link_text?: string
|
link_text?: string
|
||||||
pageConnection: Edges<ExternalLink | PageLink>
|
pageConnection: Edges<TempPageLink | PageLink>
|
||||||
system: {
|
system: {
|
||||||
uid: string
|
uid: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import { Lang } from "@/types/lang"
|
||||||
import type { EmbedEnum } from "./embeds"
|
import type { EmbedEnum } from "./embeds"
|
||||||
import type { Typename } from "./typename"
|
import type { Typename } from "./typename"
|
||||||
|
|
||||||
export type PageLink = {
|
export type PageLink = {
|
||||||
system: {
|
system: {
|
||||||
uid: string
|
uid: string
|
||||||
|
locale: Lang
|
||||||
}
|
}
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
|
import { Lang } from "@/types/lang"
|
||||||
import type { EmbedEnum } from "./embeds"
|
import type { EmbedEnum } from "./embeds"
|
||||||
import type { Typename } from "./typename"
|
import type { Typename } from "./typename"
|
||||||
|
|
||||||
export type ExternalLink = {
|
export type TempPageLink = {
|
||||||
system: {
|
system: {
|
||||||
uid: string
|
uid: string
|
||||||
|
locale: Lang
|
||||||
}
|
}
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ExternalLinkType = Typename<ExternalLink, EmbedEnum.TempPage>
|
export type TempPageLinkType = Typename<TempPageLink, EmbedEnum.TempPage>
|
||||||
Reference in New Issue
Block a user