fix: dbDelta separate tables, add SEOHead for page titles
1. License table creation: - dbDelta requires separate calls per CREATE TABLE - Split into sql_licenses and sql_activations - Added 'PRIMARY KEY (id)' with two spaces (dbDelta requirement) 2. Page titles: - Added SEOHead to Cart page (title: Shopping Cart) - Added SEOHead to Checkout page (title: Checkout) - Shop already had SEOHead 3. usePageTitle hook created (alternative to SEOHead for non-Helmet usage)
This commit is contained in:
22
customer-spa/src/hooks/usePageTitle.ts
Normal file
22
customer-spa/src/hooks/usePageTitle.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
/**
|
||||
* Hook to set the document title dynamically
|
||||
* @param title - The page title to set
|
||||
* @param suffix - Optional suffix (default: store name from settings)
|
||||
*/
|
||||
export function usePageTitle(title: string, suffix?: string) {
|
||||
useEffect(() => {
|
||||
const storeName = (window as any).woonoowCustomer?.storeName || 'Store';
|
||||
const finalSuffix = suffix ?? storeName;
|
||||
|
||||
document.title = title ? `${title} | ${finalSuffix}` : finalSuffix;
|
||||
|
||||
// Cleanup: restore original title when component unmounts
|
||||
return () => {
|
||||
// Don't restore - let the next page set its own title
|
||||
};
|
||||
}, [title, suffix]);
|
||||
}
|
||||
|
||||
export default usePageTitle;
|
||||
Reference in New Issue
Block a user