Skip to content

Commit

Permalink
fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Feb 20, 2024
1 parent db8677b commit 98c5107
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/astro/src/core/routing/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { AstroError } from '../../errors/index.js';
import { removeLeadingForwardSlash, slash } from '../../path.js';
import { resolvePages } from '../../util.js';
import { getRouteGenerator } from './generator.js';
import { toRoutingStrategy } from '../../../i18n/utils.js';
const require = createRequire(import.meta.url);

interface Item {
Expand Down Expand Up @@ -686,8 +687,9 @@ export function createRouteManifest(

const i18n = settings.config.i18n;
if (i18n) {
const strategy = toRoutingStrategy(i18n);
// First we check if the user doesn't have an index page.
if (i18n.routing.prefixDefaultLocale === true) {
if (strategy === 'pathname-prefix-always') {
let index = routes.find((route) => route.route === '/');
if (!index) {
let relativePath = path.relative(
Expand Down Expand Up @@ -755,7 +757,7 @@ export function createRouteManifest(

// Work done, now we start creating "fallback" routes based on the configuration

if (i18n.routing.prefixDefaultLocale === true) {
if (strategy === 'pathname-prefix-always') {
// we attempt to retrieve the index page of the default locale
const defaultLocaleRoutes = routesByLocale.get(i18n.defaultLocale);
if (defaultLocaleRoutes) {
Expand Down Expand Up @@ -830,7 +832,7 @@ export function createRouteManifest(
let route: string;
if (
fallbackToLocale === i18n.defaultLocale &&
i18n.routing.prefixDefaultLocale === false
strategy === 'pathname-prefix-other-locales'
) {
if (fallbackToRoute.pathname) {
pathname = `/${fallbackFromLocale}${fallbackToRoute.pathname}`;
Expand Down

0 comments on commit 98c5107

Please sign in to comment.