Skip to content

Commit 1a02c6d

Browse files
Add redirect to redirectPath if a user lands on a tutorial page with redirectPath set (#2013)
Co-authored-by: Your Name <youremail@yourdomain.com>
1 parent 914d355 commit 1a02c6d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.changeset/fiery-suits-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nextjs-website": patch
3+
---
4+
5+
Add redirect to redirectPath if a user lands on a tutorial page with redirectPath set

apps/nextjs-website/src/app/[locale]/[productSlug]/tutorials/[...productTutorialPage]/page.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
productToBreadcrumb,
1212
} from '@/helpers/structuredData.helpers';
1313

14+
import { redirect } from 'next/navigation';
15+
1416
type Params = {
1517
locale: string;
1618
productSlug: string;
@@ -45,6 +47,13 @@ const Page = async (props: { params: Promise<Params> }) => {
4547

4648
const strapiTutorialProps = await getTutorial(productSlug, [tutorialPath]);
4749

50+
if (
51+
strapiTutorialProps.redirectPath &&
52+
strapiTutorialProps.redirectPath !== strapiTutorialProps.path
53+
) {
54+
redirect(strapiTutorialProps.redirectPath);
55+
}
56+
4857
const structuredData = generateStructuredDataScripts({
4958
breadcrumbsItems: [
5059
productToBreadcrumb(params.locale, strapiTutorialProps.product),

0 commit comments

Comments
 (0)