create-brainerce-store 1.27.4 → 1.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -1
- package/package.json +1 -1
- package/templates/nextjs/base/src/app/account/page.tsx +1 -1
- package/templates/nextjs/base/src/app/auth/callback/page.tsx +2 -1
- package/templates/nextjs/base/src/app/cart/page.tsx +1 -1
- package/templates/nextjs/base/src/app/checkout/page.tsx +1 -1
- package/templates/nextjs/base/src/app/forgot-password/page.tsx +1 -1
- package/templates/nextjs/base/src/app/layout.tsx.ejs +6 -5
- package/templates/nextjs/base/src/app/login/page.tsx +1 -2
- package/templates/nextjs/base/src/app/order-confirmation/page.tsx +1 -1
- package/templates/nextjs/base/src/app/page.tsx +1 -1
- package/templates/nextjs/base/src/app/products/page.tsx +475 -470
- package/templates/nextjs/base/src/app/register/page.tsx +1 -2
- package/templates/nextjs/base/src/app/reset-password/page.tsx +1 -2
- package/templates/nextjs/base/src/app/verify-email/page.tsx +1 -2
- package/templates/nextjs/base/src/components/auth/login-form.tsx +1 -1
- package/templates/nextjs/base/src/components/layout/footer.tsx +1 -1
- package/templates/nextjs/base/src/components/layout/header.tsx +1 -2
- package/templates/nextjs/base/src/components/products/product-card.tsx +1 -2
- package/templates/nextjs/base/src/components/products/recommendation-section.tsx +1 -1
- package/templates/nextjs/base/src/lib/navigation.tsx.ejs +60 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { useRouter } from '
|
|
5
|
-
import Link from 'next/link';
|
|
4
|
+
import { useRouter, Link } from '@/lib/navigation';
|
|
6
5
|
import { useAuth } from '@/providers/store-provider';
|
|
7
6
|
import { proxyRegister } from '@/lib/auth';
|
|
8
7
|
import { RegisterForm } from '@/components/auth/register-form';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { useRouter } from '
|
|
5
|
-
import Link from 'next/link';
|
|
4
|
+
import { useRouter, Link } from '@/lib/navigation';
|
|
6
5
|
import { proxyResetPassword } from '@/lib/auth';
|
|
7
6
|
import { LoadingSpinner } from '@/components/shared/loading-spinner';
|
|
8
7
|
import { useTranslations } from '@/lib/translations';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { Suspense, useState, useRef, useEffect, useCallback } from 'react';
|
|
4
|
-
import { useRouter } from '
|
|
5
|
-
import Link from 'next/link';
|
|
4
|
+
import { useRouter, Link } from '@/lib/navigation';
|
|
6
5
|
import { useAuth } from '@/providers/store-provider';
|
|
7
6
|
import { proxyVerifyEmail, proxyResendVerification } from '@/lib/auth';
|
|
8
7
|
import { LoadingSpinner } from '@/components/shared/loading-spinner';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import Link from '
|
|
4
|
+
import { Link } from '@/lib/navigation';
|
|
5
5
|
import { useTranslations } from '@/lib/translations';
|
|
6
6
|
import { cn } from '@/lib/utils';
|
|
7
7
|
import { LoadingSpinner } from '@/components/shared/loading-spinner';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
4
|
-
import Link from '
|
|
4
|
+
import { Link, useRouter } from '@/lib/navigation';
|
|
5
5
|
import Image from 'next/image';
|
|
6
|
-
import { useRouter } from 'next/navigation';
|
|
7
6
|
import type { SearchSuggestions, ProductSuggestion } from 'brainerce';
|
|
8
7
|
import { formatPrice } from 'brainerce';
|
|
9
8
|
import { getClient } from '@/lib/brainerce';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import Link from '
|
|
5
|
-
import { useRouter } from 'next/navigation';
|
|
4
|
+
import { Link, useRouter } from '@/lib/navigation';
|
|
6
5
|
import Image from 'next/image';
|
|
7
6
|
import type { Product } from 'brainerce';
|
|
8
7
|
import { getProductPriceInfo, getVariantPrice, formatPrice } from 'brainerce';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
|
-
import Link from '
|
|
4
|
+
import { Link } from '@/lib/navigation';
|
|
5
5
|
import Image from 'next/image';
|
|
6
6
|
import type { ProductRecommendation } from 'brainerce';
|
|
7
7
|
import { PriceDisplay } from '@/components/shared/price-display';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<% if (i18nEnabled) { %>
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import NextLink from 'next/link';
|
|
6
|
+
import { useRouter as useNextRouter, usePathname } from 'next/navigation';
|
|
7
|
+
import type { ComponentProps } from 'react';
|
|
8
|
+
|
|
9
|
+
const supportedLocales = <%- supportedLocales %>;
|
|
10
|
+
const defaultLocale = '<%= defaultLocale %>';
|
|
11
|
+
|
|
12
|
+
function getLocale(pathname: string): string {
|
|
13
|
+
const segment = pathname.split('/')[1];
|
|
14
|
+
return supportedLocales.includes(segment) ? segment : defaultLocale;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function localizePath(path: string, locale: string): string {
|
|
18
|
+
if (!path.startsWith('/')) return path;
|
|
19
|
+
// Don't double-prefix
|
|
20
|
+
const firstSeg = path.split('/')[1];
|
|
21
|
+
if (supportedLocales.includes(firstSeg)) return path;
|
|
22
|
+
return `/${locale}${path}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Locale-aware Link — automatically prepends current locale to href.
|
|
27
|
+
*/
|
|
28
|
+
export function Link({ href, ...props }: ComponentProps<typeof NextLink>) {
|
|
29
|
+
const pathname = usePathname();
|
|
30
|
+
const locale = getLocale(pathname);
|
|
31
|
+
const localizedHref =
|
|
32
|
+
typeof href === 'string' ? localizePath(href, locale) : href;
|
|
33
|
+
return <NextLink href={localizedHref} {...props} />;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Locale-aware useRouter — push/replace automatically prepend locale.
|
|
38
|
+
*/
|
|
39
|
+
export function useRouter() {
|
|
40
|
+
const router = useNextRouter();
|
|
41
|
+
const pathname = usePathname();
|
|
42
|
+
const locale = getLocale(pathname);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...router,
|
|
46
|
+
push: (url: string, options?: Parameters<typeof router.push>[1]) => {
|
|
47
|
+
return router.push(localizePath(url, locale), options);
|
|
48
|
+
},
|
|
49
|
+
replace: (url: string, options?: Parameters<typeof router.replace>[1]) => {
|
|
50
|
+
return router.replace(localizePath(url, locale), options);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
<% } else { %>
|
|
55
|
+
/* Single-language store — re-export Next.js navigation as-is */
|
|
56
|
+
'use client';
|
|
57
|
+
|
|
58
|
+
export { default as Link } from 'next/link';
|
|
59
|
+
export { useRouter } from 'next/navigation';
|
|
60
|
+
<% } %>
|