Refactor SEO routing and page structure
- Replaced SeoProgrammaticPage with SeoRoutePage to handle dynamic routing for SEO pages. - Updated App.tsx to use SeoRoutePage for dynamic routes. - Consolidated SEO page logic into SeoPage component. - Removed individual SEO programmatic routes and replaced them with a dynamic route structure. - Added tests to ensure all routes are accounted for and dynamic SEO routes are present. - Introduced new SeoRoutePage to manage locale and slug parameters for SEO pages.
This commit is contained in:
@@ -3,6 +3,7 @@ import { readFileSync } from 'fs';
|
||||
import { resolve, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { ALL_ROUTES } from '@/config/routes';
|
||||
import { getAllSeoLandingPaths } from '@/config/seoPages';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
@@ -22,6 +23,7 @@ describe('Route safety', () => {
|
||||
resolve(__dirname, '../App.tsx'),
|
||||
'utf-8'
|
||||
);
|
||||
const seoLandingPaths = new Set(getAllSeoLandingPaths());
|
||||
|
||||
// Extract all path="..." values from <Route> elements
|
||||
const routePathRegex = /path="([^"]+)"/g;
|
||||
@@ -32,10 +34,26 @@ describe('Route safety', () => {
|
||||
}
|
||||
|
||||
it('App.tsx contains routes for every entry in the route registry', () => {
|
||||
const missing = ALL_ROUTES.filter((r) => !appPaths.has(r));
|
||||
const hasDynamicSeoRoute = appPaths.has('/:slug');
|
||||
const missing = ALL_ROUTES.filter((route) => {
|
||||
if (appPaths.has(route)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasDynamicSeoRoute && seoLandingPaths.has(route)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
expect(missing, `Missing routes in App.tsx: ${missing.join(', ')}`).toEqual([]);
|
||||
});
|
||||
|
||||
it('App.tsx contains the dynamic SEO routes', () => {
|
||||
expect(appPaths.has('/:slug')).toBe(true);
|
||||
expect(appPaths.has('/ar/:slug')).toBe(true);
|
||||
});
|
||||
|
||||
it('route registry is not empty', () => {
|
||||
expect(ALL_ROUTES.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
* (routes.test.ts) will fail if any existing route is deleted.
|
||||
*/
|
||||
|
||||
// ─── Page routes ─────────────────────────────────────────────────
|
||||
export const PAGE_ROUTES = [
|
||||
import { getAllSeoLandingPaths } from '@/config/seoPages';
|
||||
|
||||
const STATIC_PAGE_ROUTES = [
|
||||
'/',
|
||||
'/about',
|
||||
'/account',
|
||||
@@ -21,15 +22,16 @@ export const PAGE_ROUTES = [
|
||||
'/blog/:slug',
|
||||
'/developers',
|
||||
'/internal/admin',
|
||||
'/pdf-to-word',
|
||||
'/word-to-pdf',
|
||||
'/compress-pdf-online',
|
||||
'/convert-jpg-to-pdf',
|
||||
'/merge-pdf-files',
|
||||
'/remove-pdf-password',
|
||||
'/best-pdf-tools',
|
||||
'/free-pdf-tools-online',
|
||||
'/convert-files-online',
|
||||
] as const;
|
||||
|
||||
const SEO_PAGE_ROUTES = getAllSeoLandingPaths();
|
||||
|
||||
// ─── Page routes ─────────────────────────────────────────────────
|
||||
export const PAGE_ROUTES = [
|
||||
...STATIC_PAGE_ROUTES,
|
||||
...SEO_PAGE_ROUTES,
|
||||
'/:slug',
|
||||
'/ar/:slug',
|
||||
] as const;
|
||||
|
||||
// ─── Tool routes ─────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user