Skip to content

Commit

Permalink
[DEV-2116] Remove NextIntl warnings (#1316)
Browse files Browse the repository at this point in the history
* Remove NextIntl warnings

* Add changeset
  • Loading branch information
marcobottaro authored Jan 21, 2025
1 parent baa43ce commit c9b5838
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-wolves-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Remove NextIntl warnings
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const TutorialsPage = async ({ params }: ProductParams) => {
href: {
label: 'shared.readTutorial',
link: tutorial.path,
translate: true,
},
img: {
alt: tutorial.image?.alternativeText || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type GuideMenuProps = GuideMenuItemsProps & {
const GuideMenu = (menuProps: GuideMenuProps) => {
const [open, setOpen] = useState(false);
const { palette } = useTheme();
const t = useTranslations('productGuidePage');
const t = useTranslations();
const isDesktop = useMediaQuery((theme: Theme) => theme.breakpoints.up('lg'));
const scrollUp = useScrollUp();
const currentPath = usePathname();
Expand Down Expand Up @@ -107,7 +107,7 @@ const GuideMenu = (menuProps: GuideMenuProps) => {
color: palette.primary.main,
}}
>
{t('tableOfContents')}
{t('productGuidePage.tableOfContents')}
</Typography>
<IconButton
size='small'
Expand Down Expand Up @@ -140,7 +140,7 @@ const GuideMenu = (menuProps: GuideMenuProps) => {
color: palette.primary.main,
}}
>
{t('tableOfContents')}
{t('productGuidePage.tableOfContents')}
</Typography>
<IconButton
aria-label='close'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Description = {
readonly listItems?: ReadonlyArray<string>;
readonly content?: BlocksContent;
readonly title: string;
readonly translate?: boolean;
};

export type GuideCardProps = {
Expand All @@ -28,6 +29,7 @@ export type GuideCardProps = {
link: {
label: string;
href: string;
translate?: boolean;
};
mobileImagePath: string;
title: string;
Expand Down Expand Up @@ -100,7 +102,10 @@ export const GuideCard: FC<GuideCardProps> = ({
<BlocksRendererClient content={description.content} />
)}
</Box>
<LinkButton label={t(link.label)} href={link.href}></LinkButton>
<LinkButton
label={link.translate ? t(link.label) : link.label}
href={link.href}
></LinkButton>
</CardContent>
</Box>
<CardMedia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,18 @@ const PostIntegration = ({
key={index}
{...props}
description={{
title: t(props.description.title),
title: props.description.translate
? t(props.description.title)
: props.description.title,
content: props.description.content,
listItems: props.description.listItems,
}}
link={{ label: t(props.link.label), href: props.link.href }}
link={{
label: props.link.translate
? t(props.link.label)
: props.link.label,
href: props.link.href,
}}
/>
))}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface INewsroomItem {
label: string;
title?: string;
link: string;
translate?: boolean;
};
variant?: Variant;
}
Expand Down Expand Up @@ -130,7 +131,7 @@ const Item = (props: INewsroomItem) => {
<LinkButton
disabled={!!comingSoonLabel}
href={href.link}
label={t(href.label)}
label={href.translate ? t(href.label) : href.label}
/>
</Stack>
</div>
Expand Down
10 changes: 5 additions & 5 deletions apps/nextjs-website/src/helpers/breadcrumbs.helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BreadcrumbSegment, Path } from '@/lib/types/path';
import { BreadcrumbSegment } from '@/lib/types/path';
import { Product } from '@/lib/types/product';

export function productPageToBreadcrumbs(
Expand All @@ -7,7 +7,7 @@ export function productPageToBreadcrumbs(
): readonly BreadcrumbSegment[] {
return [
{
name: 'home',
name: 'breadcrumbs.home',
path: '/',
translate: true,
},
Expand All @@ -25,16 +25,16 @@ export function productPageToBreadcrumbs(

export function pageToBreadcrumbs(
pagePath: string,
paths?: readonly Path[]
paths?: readonly BreadcrumbSegment[]
): readonly BreadcrumbSegment[] {
return [
{
name: 'home',
name: 'breadcrumbs.home',
path: '/',
translate: true,
},
{
name: pagePath,
name: `breadcrumbs.${pagePath}`,
path: `/${pagePath}`,
translate: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export function makeGuideListPagesProps(
description: {
title: 'guideListPage.cardSection.listItemsTitle', // this is translations path and it will be translated by the component
listItems: attributes.listItems.map(({ text }) => text),
translate: true,
},
imagePath: attributes.image.data.attributes.url,
mobileImagePath: attributes.mobileImage.data.attributes.url,
link: {
label: 'guideListPage.cardSection.linkLabel', // this is translations path and it will be translated by the component
href: `/${product.slug}/guides/${attributes.slug}`,
translate: true,
},
})),
})),
Expand Down
4 changes: 4 additions & 0 deletions apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,29 @@ export function makeOverviewsProps(
description: {
content: document.content,
title: 'guideListPage.cardSection.listItemsTitle',
translate: false,
},
imagePath: document.image.data.attributes.url,
mobileImagePath: document.mobileImage.data.attributes.url,
link: {
label: document.linkText,
href: document.linkHref,
translate: false,
},
})),
...attributes.postIntegration.guides.data.map((guide) => ({
title: guide.attributes.title,
description: {
listItems: guide.attributes.listItems.map((item) => item.text),
title: 'guideListPage.cardSection.listItemsTitle',
translate: false,
},
imagePath: guide.attributes.image.data.attributes.url,
mobileImagePath: guide.attributes.mobileImage.data.attributes.url,
link: {
label: 'shared.goToGuide',
href: `guides/${guide.attributes.slug}`,
translate: true,
},
})),
],
Expand Down

0 comments on commit c9b5838

Please sign in to comment.