Skip to content

Commit ea64bfe

Browse files
authored
Merge pull request #1410 from prezly/fix/dev-22400-special-chars-in-slugs
[DEV-22151][DEV-12121] Automatically redirect to the current story slug
2 parents 4a1a0be + 3fe76d3 commit ea64bfe

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

app/[localeCode]/(story)/[slug]/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Locale } from '@prezly/theme-kit-nextjs';
2-
import { notFound } from 'next/navigation';
2+
import { notFound, redirect } from 'next/navigation';
33

4-
import { app, generateStoryPageMetadata } from '@/adapters/server';
4+
import { app, configureAppRouter, generateStoryPageMetadata } from '@/adapters/server';
55
import { Story } from '@/modules/Story';
66
import { parsePreviewSearchParams } from '@/utils';
77

@@ -21,6 +21,10 @@ async function resolve(params: Props['params']) {
2121
const story = await app().story({ slug });
2222
if (!story) notFound();
2323

24+
if (story.slug !== slug) {
25+
return redirect(configureAppRouter().generate('story', { slug: story.slug }));
26+
}
27+
2428
const { stories: relatedStories } = await app().stories({
2529
limit: 3,
2630
locale: localeCode,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@prezly/content-renderer-react-js": "0.44.0",
3333
"@prezly/sdk": "23.17.0",
3434
"@prezly/story-content-format": "0.70.0",
35-
"@prezly/theme-kit-nextjs": "10.5.3",
35+
"@prezly/theme-kit-nextjs": "10.5.4",
3636
"@prezly/uploadcare": "2.6.0",
3737
"@prezly/uploadcare-image": "0.3.2",
3838
"@react-hookz/web": "14.7.1",

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)