forked from cardosofelipe/fast-next-template
Refactor i18n integration and update tests for improved localization
- Updated test components (`PasswordResetConfirmForm`, `PasswordChangeForm`) to use i18n keys directly, ensuring accurate validation messages. - Refined translations in `it.json` to standardize format and content. - Replaced text-based labels with localized strings in `PasswordResetRequestForm` and `RegisterForm`. - Introduced `generateLocalizedMetadata` utility and updated layout metadata generation for locale-aware SEO. - Enhanced e2e tests with locale-prefixed routes and updated assertions for consistency. - Added comprehensive i18n documentation (`I18N.md`) for usage, architecture, and testing.
This commit is contained in:
49
frontend/src/app/sitemap.ts
Normal file
49
frontend/src/app/sitemap.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { MetadataRoute } from 'next';
|
||||
import { routing } from '@/lib/i18n/routing';
|
||||
|
||||
/**
|
||||
* Generate multilingual sitemap
|
||||
* Includes all public routes for each supported locale
|
||||
*/
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000';
|
||||
|
||||
// Define public routes that should be in sitemap
|
||||
const publicRoutes = [
|
||||
'', // homepage
|
||||
'/login',
|
||||
'/register',
|
||||
'/password-reset',
|
||||
'/demos',
|
||||
'/dev',
|
||||
'/dev/components',
|
||||
'/dev/layouts',
|
||||
'/dev/forms',
|
||||
'/dev/docs',
|
||||
];
|
||||
|
||||
// Generate sitemap entries for each locale
|
||||
const sitemapEntries: MetadataRoute.Sitemap = [];
|
||||
|
||||
routing.locales.forEach((locale) => {
|
||||
publicRoutes.forEach((route) => {
|
||||
const path = route === '' ? `/${locale}` : `/${locale}${route}`;
|
||||
|
||||
sitemapEntries.push({
|
||||
url: `${baseUrl}${path}`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: route === '' ? 'daily' : 'weekly',
|
||||
priority: route === '' ? 1.0 : 0.8,
|
||||
// Language alternates for this URL
|
||||
alternates: {
|
||||
languages: {
|
||||
en: `${baseUrl}/en${route}`,
|
||||
it: `${baseUrl}/it${route}`,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return sitemapEntries;
|
||||
}
|
||||
Reference in New Issue
Block a user