Skip to content

Commit e294053

Browse files
authored
Merge pull request #21 from Dataninja/feature/validate-language-from-path
[#19] Validate language from path
2 parents 32b2c2a + cb0234b commit e294053

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/plugin/onCreatePage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const onCreatePage = async (
8787
if (pageOptions?.getLanguageFromPath) {
8888
const result = match<{lang: string}>(pageOptions.matchPath)(page.path);
8989
if (!result) return;
90-
const language = result.params.lang || defaultLanguage;
90+
const language = languages.find((lng) => lng === result.params.lang) || defaultLanguage;
9191
const originalPath = page.path.replace(`/${language}`, '');
9292
const routed = Boolean(result.params.lang);
9393
newPage = await generatePage({language, originalPath, routed, pageOptions});

0 commit comments

Comments
 (0)