feat: migrate from HashRouter to BrowserRouter for SEO
Phase 1: WordPress Rewrite Rules - Add rewrite rule for /store/* to serve SPA page - Add use_browser_router setting toggle (default: true) - Flush rewrite rules on settings change Phase 2: React Router Migration - Add BrowserRouter with basename from WordPress config - Pass basePath and useBrowserRouter to frontend - Conditional router based on setting Phase 3: Hash Route Migration - Update EmailManager.php reset password URL - Update EmailRenderer.php login URL - Update TemplateOverride.php WC redirects - All routes now use path format by default This enables proper SEO indexing as search engines can now crawl individual product/page URLs.
This commit is contained in:
@@ -331,6 +331,7 @@ class EmailManager {
|
||||
// The SPA page (e.g., /store/) loads customer-spa which has /reset-password route
|
||||
$appearance_settings = get_option('woonoow_appearance_settings', []);
|
||||
$spa_page_id = $appearance_settings['general']['spa_page'] ?? 0;
|
||||
$use_browser_router = $appearance_settings['general']['use_browser_router'] ?? true;
|
||||
|
||||
if ($spa_page_id > 0) {
|
||||
$spa_url = get_permalink($spa_page_id);
|
||||
@@ -339,9 +340,15 @@ class EmailManager {
|
||||
$spa_url = home_url('/');
|
||||
}
|
||||
|
||||
// Build SPA reset password URL with hash router format
|
||||
// Format: /store/#/reset-password?key=KEY&login=LOGIN
|
||||
$reset_link = rtrim($spa_url, '/') . '#/reset-password?key=' . $key . '&login=' . rawurlencode($user_login);
|
||||
// Build SPA reset password URL
|
||||
// Use path format for BrowserRouter (SEO), hash format for HashRouter (legacy)
|
||||
if ($use_browser_router) {
|
||||
// Path format: /store/reset-password?key=KEY&login=LOGIN
|
||||
$reset_link = trailingslashit($spa_url) . 'reset-password?key=' . $key . '&login=' . rawurlencode($user_login);
|
||||
} else {
|
||||
// Hash format: /store/#/reset-password?key=KEY&login=LOGIN
|
||||
$reset_link = rtrim($spa_url, '/') . '#/reset-password?key=' . $key . '&login=' . rawurlencode($user_login);
|
||||
}
|
||||
|
||||
// Create a pseudo WC_Customer for template rendering
|
||||
$customer = null;
|
||||
|
||||
Reference in New Issue
Block a user