@windrun-huaiin/third-ui 12.0.3 → 12.1.0
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/clerk/clerk-provider-client.d.ts +2 -2
- package/dist/clerk/clerk-provider-client.js +2 -2
- package/dist/clerk/clerk-provider-client.mjs +2 -2
- package/dist/fuma/base/custom-home-layout.d.ts +2 -2
- package/dist/fuma/base/custom-home-layout.js +2 -2
- package/dist/fuma/base/custom-home-layout.mjs +2 -2
- package/dist/fuma/fuma-page-genarator.d.ts +2 -2
- package/dist/fuma/fuma-page-genarator.js +3 -3
- package/dist/fuma/fuma-page-genarator.mjs +3 -3
- package/dist/lib/seo-util.d.ts +4 -4
- package/dist/lib/seo-util.js +8 -8
- package/dist/lib/seo-util.mjs +8 -8
- package/dist/main/footer.d.ts +2 -2
- package/dist/main/footer.js +2 -2
- package/dist/main/footer.mjs +2 -2
- package/package.json +3 -3
- package/src/clerk/clerk-provider-client.tsx +3 -3
- package/src/fuma/base/custom-home-layout.tsx +3 -3
- package/src/fuma/fuma-page-genarator.tsx +4 -4
- package/src/lib/seo-util.ts +8 -8
- package/src/main/footer.tsx +4 -4
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
interface ClerkProviderClientProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
locale: string;
|
|
5
|
-
|
|
5
|
+
localePrefixAsNeeded?: boolean;
|
|
6
6
|
defaultLocale?: string;
|
|
7
7
|
signInUrl?: string;
|
|
8
8
|
signUpUrl?: string;
|
|
@@ -10,5 +10,5 @@ interface ClerkProviderClientProps {
|
|
|
10
10
|
fallbackSignUpUrl?: string;
|
|
11
11
|
waitlistUrl?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function ClerkProviderClient({ children, locale,
|
|
13
|
+
export declare function ClerkProviderClient({ children, locale, localePrefixAsNeeded, defaultLocale, signInUrl, signUpUrl, fallbackSignInUrl, fallbackSignUpUrl, waitlistUrl, }: ClerkProviderClientProps): import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export {};
|
|
@@ -5,11 +5,11 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
5
5
|
var clerkIntl = require('../lib/clerk-intl.js');
|
|
6
6
|
var nextjs = require('@clerk/nextjs');
|
|
7
7
|
|
|
8
|
-
function ClerkProviderClient({ children, locale,
|
|
8
|
+
function ClerkProviderClient({ children, locale, localePrefixAsNeeded = true, defaultLocale = 'en', signInUrl, signUpUrl, fallbackSignInUrl, fallbackSignUpUrl, waitlistUrl, }) {
|
|
9
9
|
var _a, _b;
|
|
10
10
|
const currentLocalization = (_b = (_a = clerkIntl.clerkIntl[locale]) !== null && _a !== void 0 ? _a : clerkIntl.clerkIntl[defaultLocale]) !== null && _b !== void 0 ? _b : clerkIntl.clerkIntl.en;
|
|
11
11
|
// In as-needed mode, skip prefixing for the default locale so /sign-in stays unprefixed.
|
|
12
|
-
const shouldPrefixLocale =
|
|
12
|
+
const shouldPrefixLocale = localePrefixAsNeeded ? locale !== defaultLocale : true;
|
|
13
13
|
const localeSegment = shouldPrefixLocale && locale ? `/${locale}` : '';
|
|
14
14
|
const buildUrl = (path) => path ? `${localeSegment}${path}` : undefined;
|
|
15
15
|
// build the ClerkProvider props, only add when the parameter is not empty
|
|
@@ -3,11 +3,11 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { clerkIntl } from '../lib/clerk-intl.mjs';
|
|
4
4
|
import { ClerkProvider } from '@clerk/nextjs';
|
|
5
5
|
|
|
6
|
-
function ClerkProviderClient({ children, locale,
|
|
6
|
+
function ClerkProviderClient({ children, locale, localePrefixAsNeeded = true, defaultLocale = 'en', signInUrl, signUpUrl, fallbackSignInUrl, fallbackSignUpUrl, waitlistUrl, }) {
|
|
7
7
|
var _a, _b;
|
|
8
8
|
const currentLocalization = (_b = (_a = clerkIntl[locale]) !== null && _a !== void 0 ? _a : clerkIntl[defaultLocale]) !== null && _b !== void 0 ? _b : clerkIntl.en;
|
|
9
9
|
// In as-needed mode, skip prefixing for the default locale so /sign-in stays unprefixed.
|
|
10
|
-
const shouldPrefixLocale =
|
|
10
|
+
const shouldPrefixLocale = localePrefixAsNeeded ? locale !== defaultLocale : true;
|
|
11
11
|
const localeSegment = shouldPrefixLocale && locale ? `/${locale}` : '';
|
|
12
12
|
const buildUrl = (path) => path ? `${localeSegment}${path}` : undefined;
|
|
13
13
|
// build the ClerkProvider props, only add when the parameter is not empty
|
|
@@ -75,7 +75,7 @@ export interface CustomHomeLayoutProps {
|
|
|
75
75
|
/**
|
|
76
76
|
* Whether localePrefix is set to 'as-needed' (default: true)
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
localePrefixAsNeeded?: boolean;
|
|
79
79
|
/**
|
|
80
80
|
* The default locale for the application (default: 'en')
|
|
81
81
|
*/
|
|
@@ -87,7 +87,7 @@ export interface HeaderActionOrders {
|
|
|
87
87
|
mobileBar?: MobileBarAction[];
|
|
88
88
|
mobileMenu?: MobileMenuAction[];
|
|
89
89
|
}
|
|
90
|
-
export declare function CustomHomeLayout({ locale, options, children, showBanner, bannerHeight, headerHeight, headerPaddingTop, navbarClassName, banner, footer, goToTop, showFooter, showGoToTop, style, floatingNav, actionOrders,
|
|
90
|
+
export declare function CustomHomeLayout({ locale, options, children, showBanner, bannerHeight, headerHeight, headerPaddingTop, navbarClassName, banner, footer, goToTop, showFooter, showGoToTop, style, floatingNav, actionOrders, localePrefixAsNeeded, defaultLocale, }: CustomHomeLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
91
91
|
export declare function HomeTitle({ children, className, }: {
|
|
92
92
|
children: ReactNode;
|
|
93
93
|
className?: string;
|
|
@@ -8,7 +8,7 @@ var footer = require('../../main/footer.js');
|
|
|
8
8
|
var goToTop = require('../../main/go-to-top.js');
|
|
9
9
|
var customHeader = require('./custom-header.js');
|
|
10
10
|
|
|
11
|
-
function CustomHomeLayout({ locale, options, children, showBanner = false, bannerHeight, headerHeight = 2.5, headerPaddingTop, navbarClassName, banner, footer: footer$1, goToTop: goToTop$1, showFooter = true, showGoToTop = true, style, floatingNav = false, actionOrders,
|
|
11
|
+
function CustomHomeLayout({ locale, options, children, showBanner = false, bannerHeight, headerHeight = 2.5, headerPaddingTop, navbarClassName, banner, footer: footer$1, goToTop: goToTop$1, showFooter = true, showGoToTop = true, style, floatingNav = false, actionOrders, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
|
|
12
12
|
const resolvedBannerHeight = bannerHeight !== null && bannerHeight !== void 0 ? bannerHeight : (showBanner ? 3 : 0.5);
|
|
13
13
|
const resolvedPaddingTop = headerPaddingTop !== null && headerPaddingTop !== void 0 ? headerPaddingTop : (showBanner ? 0 : 0.5);
|
|
14
14
|
const layoutStyle = Object.assign({ '--fd-banner-height': `${resolvedBannerHeight}rem`, '--fd-nav-height': `${headerHeight}rem`, paddingTop: floatingNav
|
|
@@ -17,7 +17,7 @@ function CustomHomeLayout({ locale, options, children, showBanner = false, banne
|
|
|
17
17
|
const { nav } = options, homeLayoutProps = tslib_es6.__rest(options, ["nav"]);
|
|
18
18
|
const navOptions = nav !== null && nav !== void 0 ? nav : {};
|
|
19
19
|
const header = (jsxRuntime.jsx(customHeader.CustomHomeHeader, Object.assign({}, homeLayoutProps, { nav: navOptions, bannerHeight: resolvedBannerHeight, headerHeight: headerHeight, navbarClassName: navbarClassName, floating: floatingNav, desktopActionsOrder: actionOrders === null || actionOrders === void 0 ? void 0 : actionOrders.desktop, mobileBarActionsOrder: actionOrders === null || actionOrders === void 0 ? void 0 : actionOrders.mobileBar, mobileMenuActionsOrder: actionOrders === null || actionOrders === void 0 ? void 0 : actionOrders.mobileMenu })));
|
|
20
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [banner !== null && banner !== void 0 ? banner : (jsxRuntime.jsx(fumaBannerSuit.FumaBannerSuit, { locale: locale, showBanner: showBanner, floating: floatingNav })), jsxRuntime.jsxs(home.HomeLayout, Object.assign({}, homeLayoutProps, { nav: Object.assign(Object.assign({}, navOptions), { component: header }), className: 'bg-neutral-100 dark:bg-neutral-900', style: layoutStyle, children: [children, showFooter ? footer$1 !== null && footer$1 !== void 0 ? footer$1 : jsxRuntime.jsx(footer.Footer, { locale: locale,
|
|
20
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [banner !== null && banner !== void 0 ? banner : (jsxRuntime.jsx(fumaBannerSuit.FumaBannerSuit, { locale: locale, showBanner: showBanner, floating: floatingNav })), jsxRuntime.jsxs(home.HomeLayout, Object.assign({}, homeLayoutProps, { nav: Object.assign(Object.assign({}, navOptions), { component: header }), className: 'bg-neutral-100 dark:bg-neutral-900', style: layoutStyle, children: [children, showFooter ? footer$1 !== null && footer$1 !== void 0 ? footer$1 : jsxRuntime.jsx(footer.Footer, { locale: locale, localePrefixAsNeeded: localePrefixAsNeeded, defaultLocale: defaultLocale }) : null, showGoToTop ? goToTop$1 !== null && goToTop$1 !== void 0 ? goToTop$1 : jsxRuntime.jsx(goToTop.GoToTop, {}) : null] }))] }));
|
|
21
21
|
}
|
|
22
22
|
function HomeTitle({ children, className, }) {
|
|
23
23
|
return (jsxRuntime.jsx("span", { className: `font-medium in-[.uwu]:hidden in-[header]:text-[clamp(12px,3vw,15px)]! ${className !== null && className !== void 0 ? className : ''}`, children: children }));
|
|
@@ -6,7 +6,7 @@ import { Footer } from '../../main/footer.mjs';
|
|
|
6
6
|
import { GoToTop } from '../../main/go-to-top.mjs';
|
|
7
7
|
import { CustomHomeHeader } from './custom-header.mjs';
|
|
8
8
|
|
|
9
|
-
function CustomHomeLayout({ locale, options, children, showBanner = false, bannerHeight, headerHeight = 2.5, headerPaddingTop, navbarClassName, banner, footer, goToTop, showFooter = true, showGoToTop = true, style, floatingNav = false, actionOrders,
|
|
9
|
+
function CustomHomeLayout({ locale, options, children, showBanner = false, bannerHeight, headerHeight = 2.5, headerPaddingTop, navbarClassName, banner, footer, goToTop, showFooter = true, showGoToTop = true, style, floatingNav = false, actionOrders, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
|
|
10
10
|
const resolvedBannerHeight = bannerHeight !== null && bannerHeight !== void 0 ? bannerHeight : (showBanner ? 3 : 0.5);
|
|
11
11
|
const resolvedPaddingTop = headerPaddingTop !== null && headerPaddingTop !== void 0 ? headerPaddingTop : (showBanner ? 0 : 0.5);
|
|
12
12
|
const layoutStyle = Object.assign({ '--fd-banner-height': `${resolvedBannerHeight}rem`, '--fd-nav-height': `${headerHeight}rem`, paddingTop: floatingNav
|
|
@@ -15,7 +15,7 @@ function CustomHomeLayout({ locale, options, children, showBanner = false, banne
|
|
|
15
15
|
const { nav } = options, homeLayoutProps = __rest(options, ["nav"]);
|
|
16
16
|
const navOptions = nav !== null && nav !== void 0 ? nav : {};
|
|
17
17
|
const header = (jsx(CustomHomeHeader, Object.assign({}, homeLayoutProps, { nav: navOptions, bannerHeight: resolvedBannerHeight, headerHeight: headerHeight, navbarClassName: navbarClassName, floating: floatingNav, desktopActionsOrder: actionOrders === null || actionOrders === void 0 ? void 0 : actionOrders.desktop, mobileBarActionsOrder: actionOrders === null || actionOrders === void 0 ? void 0 : actionOrders.mobileBar, mobileMenuActionsOrder: actionOrders === null || actionOrders === void 0 ? void 0 : actionOrders.mobileMenu })));
|
|
18
|
-
return (jsxs(Fragment, { children: [banner !== null && banner !== void 0 ? banner : (jsx(FumaBannerSuit, { locale: locale, showBanner: showBanner, floating: floatingNav })), jsxs(HomeLayout, Object.assign({}, homeLayoutProps, { nav: Object.assign(Object.assign({}, navOptions), { component: header }), className: 'bg-neutral-100 dark:bg-neutral-900', style: layoutStyle, children: [children, showFooter ? footer !== null && footer !== void 0 ? footer : jsx(Footer, { locale: locale,
|
|
18
|
+
return (jsxs(Fragment, { children: [banner !== null && banner !== void 0 ? banner : (jsx(FumaBannerSuit, { locale: locale, showBanner: showBanner, floating: floatingNav })), jsxs(HomeLayout, Object.assign({}, homeLayoutProps, { nav: Object.assign(Object.assign({}, navOptions), { component: header }), className: 'bg-neutral-100 dark:bg-neutral-900', style: layoutStyle, children: [children, showFooter ? footer !== null && footer !== void 0 ? footer : jsx(Footer, { locale: locale, localePrefixAsNeeded: localePrefixAsNeeded, defaultLocale: defaultLocale }) : null, showGoToTop ? goToTop !== null && goToTop !== void 0 ? goToTop : jsx(GoToTop, {}) : null] }))] }));
|
|
19
19
|
}
|
|
20
20
|
function HomeTitle({ children, className, }) {
|
|
21
21
|
return (jsx("span", { className: `font-medium in-[.uwu]:hidden in-[header]:text-[clamp(12px,3vw,15px)]! ${className !== null && className !== void 0 ? className : ''}`, children: children }));
|
|
@@ -15,10 +15,10 @@ interface FumaPageParams {
|
|
|
15
15
|
showBreadcrumb?: boolean;
|
|
16
16
|
showTableOfContent?: boolean;
|
|
17
17
|
showTableOfContentPopover?: boolean;
|
|
18
|
-
|
|
18
|
+
localePrefixAsNeeded?: boolean;
|
|
19
19
|
defaultLocale?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales, showBreadcrumb, showTableOfContent, showTableOfContentPopover,
|
|
21
|
+
export declare function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales, showBreadcrumb, showTableOfContent, showTableOfContentPopover, localePrefixAsNeeded, defaultLocale, }: FumaPageParams): {
|
|
22
22
|
Page: ({ params }: {
|
|
23
23
|
params: Promise<{
|
|
24
24
|
locale: string;
|
|
@@ -7,7 +7,7 @@ var React = require('react');
|
|
|
7
7
|
var tocFooterWrapper = require('./mdx/toc-footer-wrapper.js');
|
|
8
8
|
var lib = require('@windrun-huaiin/lib');
|
|
9
9
|
|
|
10
|
-
function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false,
|
|
10
|
+
function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
|
|
11
11
|
const Page = function Page(_a) {
|
|
12
12
|
return tslib_es6.__awaiter(this, arguments, void 0, function* ({ params }) {
|
|
13
13
|
var _b, _c, _d;
|
|
@@ -50,12 +50,12 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
|
|
|
50
50
|
const baseRoute = mdxSourceDir.replace('src/mdx/', '');
|
|
51
51
|
// build the current page path
|
|
52
52
|
const currentPath = slug ? slug.join('/') : '';
|
|
53
|
-
const localizedPath = lib.getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`,
|
|
53
|
+
const localizedPath = lib.getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
|
|
54
54
|
const currentUrl = `${baseUrl}${localizedPath}`;
|
|
55
55
|
// generate the seo language map
|
|
56
56
|
const seoLanguageMap = {};
|
|
57
57
|
supportedLocales.forEach(loc => {
|
|
58
|
-
const seoPath = lib.getAsNeededLocalizedUrl(loc, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`,
|
|
58
|
+
const seoPath = lib.getAsNeededLocalizedUrl(loc, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
|
|
59
59
|
seoLanguageMap[loc] = `${baseUrl}${seoPath}`;
|
|
60
60
|
});
|
|
61
61
|
return {
|
|
@@ -5,7 +5,7 @@ import { cloneElement } from 'react';
|
|
|
5
5
|
import { TocFooterWrapper } from './mdx/toc-footer-wrapper.mjs';
|
|
6
6
|
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
|
|
7
7
|
|
|
8
|
-
function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false,
|
|
8
|
+
function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
|
|
9
9
|
const Page = function Page(_a) {
|
|
10
10
|
return __awaiter(this, arguments, void 0, function* ({ params }) {
|
|
11
11
|
var _b, _c, _d;
|
|
@@ -48,12 +48,12 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
|
|
|
48
48
|
const baseRoute = mdxSourceDir.replace('src/mdx/', '');
|
|
49
49
|
// build the current page path
|
|
50
50
|
const currentPath = slug ? slug.join('/') : '';
|
|
51
|
-
const localizedPath = getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`,
|
|
51
|
+
const localizedPath = getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
|
|
52
52
|
const currentUrl = `${baseUrl}${localizedPath}`;
|
|
53
53
|
// generate the seo language map
|
|
54
54
|
const seoLanguageMap = {};
|
|
55
55
|
supportedLocales.forEach(loc => {
|
|
56
|
-
const seoPath = getAsNeededLocalizedUrl(loc, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`,
|
|
56
|
+
const seoPath = getAsNeededLocalizedUrl(loc, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
|
|
57
57
|
seoLanguageMap[loc] = `${baseUrl}${seoPath}`;
|
|
58
58
|
});
|
|
59
59
|
return {
|
package/dist/lib/seo-util.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ export declare function generateRobots(baseUrl: string): MetadataRoute.Robots;
|
|
|
11
11
|
* @param locales - Supported locales array
|
|
12
12
|
* @param mdxSourceDir - MDX source directory path
|
|
13
13
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
14
|
-
* @param
|
|
14
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
15
15
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
16
16
|
* @returns Sitemap entries
|
|
17
17
|
*/
|
|
18
|
-
export declare function generateSitemap(baseUrl: string, locales: string[], mdxSourceDir: string, openMdxSEOSiteMap?: boolean,
|
|
18
|
+
export declare function generateSitemap(baseUrl: string, locales: string[], mdxSourceDir: string, openMdxSEOSiteMap?: boolean, localePrefixAsNeeded?: boolean, defaultLocale?: string): MetadataRoute.Sitemap;
|
|
19
19
|
/**
|
|
20
20
|
* Create robots.txt handler function
|
|
21
21
|
* @param baseUrl - The base URL of the website
|
|
@@ -28,8 +28,8 @@ export declare function createRobotsHandler(baseUrl: string): () => MetadataRout
|
|
|
28
28
|
* @param locales - Supported locales array
|
|
29
29
|
* @param mdxSourceDir - MDX source directory path, default is empty
|
|
30
30
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
31
|
-
* @param
|
|
31
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
32
32
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
33
33
|
* @returns Sitemap handler function
|
|
34
34
|
*/
|
|
35
|
-
export declare function createSitemapHandler(baseUrl: string, locales: string[], mdxSourceDir?: string, openMdxSEOSiteMap?: boolean,
|
|
35
|
+
export declare function createSitemapHandler(baseUrl: string, locales: string[], mdxSourceDir?: string, openMdxSEOSiteMap?: boolean, localePrefixAsNeeded?: boolean, defaultLocale?: string): () => MetadataRoute.Sitemap;
|
package/dist/lib/seo-util.js
CHANGED
|
@@ -34,11 +34,11 @@ function generateRobots(baseUrl) {
|
|
|
34
34
|
* @param locales - Supported locales array
|
|
35
35
|
* @param mdxSourceDir - MDX source directory path
|
|
36
36
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
37
|
-
* @param
|
|
37
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
38
38
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
39
39
|
* @returns Sitemap entries
|
|
40
40
|
*/
|
|
41
|
-
function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true,
|
|
41
|
+
function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true, localePrefixAsNeeded = true, defaultLocale = 'en') {
|
|
42
42
|
// 2. handle index.mdx (blog start page) and other slugs
|
|
43
43
|
const blogRoutes = [];
|
|
44
44
|
// 1. read all blog mdx file names with error handling
|
|
@@ -51,7 +51,7 @@ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = tru
|
|
|
51
51
|
for (const locale of locales) {
|
|
52
52
|
for (const f of blogFiles) {
|
|
53
53
|
if (f === 'index.mdx') {
|
|
54
|
-
const localizedPath = lib.getAsNeededLocalizedUrl(locale, '/blog',
|
|
54
|
+
const localizedPath = lib.getAsNeededLocalizedUrl(locale, '/blog', localePrefixAsNeeded, defaultLocale);
|
|
55
55
|
blogRoutes.push({
|
|
56
56
|
url: `${baseUrl}${localizedPath}`,
|
|
57
57
|
lastModified: new Date(),
|
|
@@ -61,7 +61,7 @@ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = tru
|
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
const slug = f.replace(/\.mdx$/, '');
|
|
64
|
-
const localizedPath = lib.getAsNeededLocalizedUrl(locale, `/blog/${slug}`,
|
|
64
|
+
const localizedPath = lib.getAsNeededLocalizedUrl(locale, `/blog/${slug}`, localePrefixAsNeeded, defaultLocale);
|
|
65
65
|
blogRoutes.push({
|
|
66
66
|
url: `${baseUrl}${localizedPath}`,
|
|
67
67
|
lastModified: new Date(),
|
|
@@ -80,7 +80,7 @@ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = tru
|
|
|
80
80
|
}
|
|
81
81
|
// 3. main page (all language versions)
|
|
82
82
|
const mainRoutes = locales.map(locale => {
|
|
83
|
-
const localizedPath = lib.getAsNeededLocalizedUrl(locale, '/',
|
|
83
|
+
const localizedPath = lib.getAsNeededLocalizedUrl(locale, '/', localePrefixAsNeeded, defaultLocale);
|
|
84
84
|
return {
|
|
85
85
|
url: `${baseUrl}${localizedPath}`,
|
|
86
86
|
lastModified: new Date(),
|
|
@@ -106,14 +106,14 @@ function createRobotsHandler(baseUrl) {
|
|
|
106
106
|
* @param locales - Supported locales array
|
|
107
107
|
* @param mdxSourceDir - MDX source directory path, default is empty
|
|
108
108
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
109
|
-
* @param
|
|
109
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
110
110
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
111
111
|
* @returns Sitemap handler function
|
|
112
112
|
*/
|
|
113
|
-
function createSitemapHandler(baseUrl, locales, mdxSourceDir = '', openMdxSEOSiteMap = true,
|
|
113
|
+
function createSitemapHandler(baseUrl, locales, mdxSourceDir = '', openMdxSEOSiteMap = true, localePrefixAsNeeded = true, defaultLocale = 'en') {
|
|
114
114
|
// force static generation
|
|
115
115
|
const sitemapHandler = function sitemap() {
|
|
116
|
-
return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap,
|
|
116
|
+
return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap, localePrefixAsNeeded, defaultLocale);
|
|
117
117
|
};
|
|
118
118
|
// Add static generation directive
|
|
119
119
|
sitemapHandler.dynamic = 'force-static';
|
package/dist/lib/seo-util.mjs
CHANGED
|
@@ -32,11 +32,11 @@ function generateRobots(baseUrl) {
|
|
|
32
32
|
* @param locales - Supported locales array
|
|
33
33
|
* @param mdxSourceDir - MDX source directory path
|
|
34
34
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
35
|
-
* @param
|
|
35
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
36
36
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
37
37
|
* @returns Sitemap entries
|
|
38
38
|
*/
|
|
39
|
-
function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true,
|
|
39
|
+
function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true, localePrefixAsNeeded = true, defaultLocale = 'en') {
|
|
40
40
|
// 2. handle index.mdx (blog start page) and other slugs
|
|
41
41
|
const blogRoutes = [];
|
|
42
42
|
// 1. read all blog mdx file names with error handling
|
|
@@ -49,7 +49,7 @@ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = tru
|
|
|
49
49
|
for (const locale of locales) {
|
|
50
50
|
for (const f of blogFiles) {
|
|
51
51
|
if (f === 'index.mdx') {
|
|
52
|
-
const localizedPath = getAsNeededLocalizedUrl(locale, '/blog',
|
|
52
|
+
const localizedPath = getAsNeededLocalizedUrl(locale, '/blog', localePrefixAsNeeded, defaultLocale);
|
|
53
53
|
blogRoutes.push({
|
|
54
54
|
url: `${baseUrl}${localizedPath}`,
|
|
55
55
|
lastModified: new Date(),
|
|
@@ -59,7 +59,7 @@ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = tru
|
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
const slug = f.replace(/\.mdx$/, '');
|
|
62
|
-
const localizedPath = getAsNeededLocalizedUrl(locale, `/blog/${slug}`,
|
|
62
|
+
const localizedPath = getAsNeededLocalizedUrl(locale, `/blog/${slug}`, localePrefixAsNeeded, defaultLocale);
|
|
63
63
|
blogRoutes.push({
|
|
64
64
|
url: `${baseUrl}${localizedPath}`,
|
|
65
65
|
lastModified: new Date(),
|
|
@@ -78,7 +78,7 @@ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = tru
|
|
|
78
78
|
}
|
|
79
79
|
// 3. main page (all language versions)
|
|
80
80
|
const mainRoutes = locales.map(locale => {
|
|
81
|
-
const localizedPath = getAsNeededLocalizedUrl(locale, '/',
|
|
81
|
+
const localizedPath = getAsNeededLocalizedUrl(locale, '/', localePrefixAsNeeded, defaultLocale);
|
|
82
82
|
return {
|
|
83
83
|
url: `${baseUrl}${localizedPath}`,
|
|
84
84
|
lastModified: new Date(),
|
|
@@ -104,14 +104,14 @@ function createRobotsHandler(baseUrl) {
|
|
|
104
104
|
* @param locales - Supported locales array
|
|
105
105
|
* @param mdxSourceDir - MDX source directory path, default is empty
|
|
106
106
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
107
|
-
* @param
|
|
107
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
108
108
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
109
109
|
* @returns Sitemap handler function
|
|
110
110
|
*/
|
|
111
|
-
function createSitemapHandler(baseUrl, locales, mdxSourceDir = '', openMdxSEOSiteMap = true,
|
|
111
|
+
function createSitemapHandler(baseUrl, locales, mdxSourceDir = '', openMdxSEOSiteMap = true, localePrefixAsNeeded = true, defaultLocale = 'en') {
|
|
112
112
|
// force static generation
|
|
113
113
|
const sitemapHandler = function sitemap() {
|
|
114
|
-
return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap,
|
|
114
|
+
return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap, localePrefixAsNeeded, defaultLocale);
|
|
115
115
|
};
|
|
116
116
|
// Add static generation directive
|
|
117
117
|
sitemapHandler.dynamic = 'force-static';
|
package/dist/main/footer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
interface FooterProps {
|
|
2
2
|
locale: string;
|
|
3
|
-
|
|
3
|
+
localePrefixAsNeeded?: boolean;
|
|
4
4
|
defaultLocale?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function Footer({ locale,
|
|
6
|
+
export declare function Footer({ locale, localePrefixAsNeeded, defaultLocale }: FooterProps): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
7
7
|
export {};
|
package/dist/main/footer.js
CHANGED
|
@@ -10,7 +10,7 @@ var tIntl = require('../lib/t-intl.js');
|
|
|
10
10
|
var lib = require('@windrun-huaiin/lib');
|
|
11
11
|
|
|
12
12
|
function Footer(_a) {
|
|
13
|
-
return tslib_es6.__awaiter(this, arguments, void 0, function* ({ locale,
|
|
13
|
+
return tslib_es6.__awaiter(this, arguments, void 0, function* ({ locale, localePrefixAsNeeded = true, defaultLocale = 'en' }) {
|
|
14
14
|
const tFooter = yield server.getTranslations({ locale, namespace: 'footer' });
|
|
15
15
|
const company = tIntl.safeT(tFooter, 'company', '');
|
|
16
16
|
const data = {
|
|
@@ -22,7 +22,7 @@ function Footer(_a) {
|
|
|
22
22
|
clickToCopyText: tIntl.safeT(tFooter, 'clickToCopy', 'Click to copy'),
|
|
23
23
|
copiedText: tIntl.safeT(tFooter, 'copied', 'Copied!'),
|
|
24
24
|
};
|
|
25
|
-
return (jsxRuntime.jsx("div", { className: "mb-10 w-full mx-auto border-t-purple-700/80 border-t", children: jsxRuntime.jsx("footer", { children: jsxRuntime.jsxs("div", { className: "w-full flex flex-col items-center justify-center px-4 py-8 space-y-3", children: [jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-xs sm:text-sm sm:gap-x-6", children: [jsxRuntime.jsxs(Link, { href: lib.getAsNeededLocalizedUrl(locale, "/legal/terms",
|
|
25
|
+
return (jsxRuntime.jsx("div", { className: "mb-10 w-full mx-auto border-t-purple-700/80 border-t", children: jsxRuntime.jsx("footer", { children: jsxRuntime.jsxs("div", { className: "w-full flex flex-col items-center justify-center px-4 py-8 space-y-3", children: [jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-xs sm:text-sm sm:gap-x-6", children: [jsxRuntime.jsxs(Link, { href: lib.getAsNeededLocalizedUrl(locale, "/legal/terms", localePrefixAsNeeded, defaultLocale), className: "flex items-center space-x-1 hover:underline", children: [jsxRuntime.jsx(server$1.globalLucideIcons.ReceiptText, { className: "h-3.5 w-3.5" }), jsxRuntime.jsx("span", { children: data.terms })] }), jsxRuntime.jsxs(Link, { href: lib.getAsNeededLocalizedUrl(locale, "/legal/privacy", localePrefixAsNeeded, defaultLocale), className: "flex items-center space-x-1 hover:underline", children: [jsxRuntime.jsx(server$1.globalLucideIcons.ShieldUser, { className: "h-3.5 w-3.5" }), jsxRuntime.jsx("span", { children: data.privacy })] }), jsxRuntime.jsxs(footerEmail.FooterEmail, { email: data.email, clickToCopyText: data.clickToCopyText, copiedText: data.copiedText, children: [jsxRuntime.jsx(server$1.globalLucideIcons.Mail, { className: "h-3.5 w-3.5" }), jsxRuntime.jsx("span", { children: data.contactUs })] })] }), jsxRuntime.jsx("div", { className: "text-xs sm:text-sm text-center", children: jsxRuntime.jsx("span", { children: data.copyright }) })] }) }) }));
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
package/dist/main/footer.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { safeT } from '../lib/t-intl.mjs';
|
|
|
8
8
|
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
|
|
9
9
|
|
|
10
10
|
function Footer(_a) {
|
|
11
|
-
return __awaiter(this, arguments, void 0, function* ({ locale,
|
|
11
|
+
return __awaiter(this, arguments, void 0, function* ({ locale, localePrefixAsNeeded = true, defaultLocale = 'en' }) {
|
|
12
12
|
const tFooter = yield getTranslations({ locale, namespace: 'footer' });
|
|
13
13
|
const company = safeT(tFooter, 'company', '');
|
|
14
14
|
const data = {
|
|
@@ -20,7 +20,7 @@ function Footer(_a) {
|
|
|
20
20
|
clickToCopyText: safeT(tFooter, 'clickToCopy', 'Click to copy'),
|
|
21
21
|
copiedText: safeT(tFooter, 'copied', 'Copied!'),
|
|
22
22
|
};
|
|
23
|
-
return (jsx("div", { className: "mb-10 w-full mx-auto border-t-purple-700/80 border-t", children: jsx("footer", { children: jsxs("div", { className: "w-full flex flex-col items-center justify-center px-4 py-8 space-y-3", children: [jsxs("div", { className: "flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-xs sm:text-sm sm:gap-x-6", children: [jsxs(Link, { href: getAsNeededLocalizedUrl(locale, "/legal/terms",
|
|
23
|
+
return (jsx("div", { className: "mb-10 w-full mx-auto border-t-purple-700/80 border-t", children: jsx("footer", { children: jsxs("div", { className: "w-full flex flex-col items-center justify-center px-4 py-8 space-y-3", children: [jsxs("div", { className: "flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-xs sm:text-sm sm:gap-x-6", children: [jsxs(Link, { href: getAsNeededLocalizedUrl(locale, "/legal/terms", localePrefixAsNeeded, defaultLocale), className: "flex items-center space-x-1 hover:underline", children: [jsx(globalLucideIcons.ReceiptText, { className: "h-3.5 w-3.5" }), jsx("span", { children: data.terms })] }), jsxs(Link, { href: getAsNeededLocalizedUrl(locale, "/legal/privacy", localePrefixAsNeeded, defaultLocale), className: "flex items-center space-x-1 hover:underline", children: [jsx(globalLucideIcons.ShieldUser, { className: "h-3.5 w-3.5" }), jsx("span", { children: data.privacy })] }), jsxs(FooterEmail, { email: data.email, clickToCopyText: data.clickToCopyText, copiedText: data.copiedText, children: [jsx(globalLucideIcons.Mail, { className: "h-3.5 w-3.5" }), jsx("span", { children: data.contactUs })] })] }), jsx("div", { className: "text-xs sm:text-sm text-center", children: jsx("span", { children: data.copyright }) })] }) }) }));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windrun-huaiin/third-ui",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Third-party integrated UI components for windrun-huaiin projects",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"react-medium-image-zoom": "^5.2.14",
|
|
87
87
|
"swiper": "^12.0.3",
|
|
88
88
|
"zod": "^4.1.12",
|
|
89
|
-
"@windrun-huaiin/
|
|
90
|
-
"@windrun-huaiin/
|
|
89
|
+
"@windrun-huaiin/lib": "^12.1.0",
|
|
90
|
+
"@windrun-huaiin/base-ui": "^12.0.0"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"clsx": "^2.1.1",
|
|
@@ -8,7 +8,7 @@ interface ClerkProviderClientProps {
|
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
locale: string;
|
|
10
10
|
// Whether localePrefix is set to 'as-needed' (default: true)
|
|
11
|
-
|
|
11
|
+
localePrefixAsNeeded?: boolean;
|
|
12
12
|
// The default locale used by the host app (default: 'en')
|
|
13
13
|
defaultLocale?: string;
|
|
14
14
|
signInUrl?: string;
|
|
@@ -21,7 +21,7 @@ interface ClerkProviderClientProps {
|
|
|
21
21
|
export function ClerkProviderClient({
|
|
22
22
|
children,
|
|
23
23
|
locale,
|
|
24
|
-
|
|
24
|
+
localePrefixAsNeeded = true,
|
|
25
25
|
defaultLocale = 'en',
|
|
26
26
|
signInUrl,
|
|
27
27
|
signUpUrl,
|
|
@@ -35,7 +35,7 @@ export function ClerkProviderClient({
|
|
|
35
35
|
clerkIntl.en;
|
|
36
36
|
|
|
37
37
|
// In as-needed mode, skip prefixing for the default locale so /sign-in stays unprefixed.
|
|
38
|
-
const shouldPrefixLocale =
|
|
38
|
+
const shouldPrefixLocale = localePrefixAsNeeded ? locale !== defaultLocale : true;
|
|
39
39
|
const localeSegment = shouldPrefixLocale && locale ? `/${locale}` : '';
|
|
40
40
|
|
|
41
41
|
const buildUrl = (path?: string) =>
|
|
@@ -89,7 +89,7 @@ export interface CustomHomeLayoutProps {
|
|
|
89
89
|
/**
|
|
90
90
|
* Whether localePrefix is set to 'as-needed' (default: true)
|
|
91
91
|
*/
|
|
92
|
-
|
|
92
|
+
localePrefixAsNeeded?: boolean;
|
|
93
93
|
/**
|
|
94
94
|
* The default locale for the application (default: 'en')
|
|
95
95
|
*/
|
|
@@ -120,7 +120,7 @@ export function CustomHomeLayout({
|
|
|
120
120
|
style,
|
|
121
121
|
floatingNav = false,
|
|
122
122
|
actionOrders,
|
|
123
|
-
|
|
123
|
+
localePrefixAsNeeded = true,
|
|
124
124
|
defaultLocale = 'en',
|
|
125
125
|
}: CustomHomeLayoutProps) {
|
|
126
126
|
const resolvedBannerHeight = bannerHeight ?? (showBanner ? 3 : 0.5);
|
|
@@ -171,7 +171,7 @@ export function CustomHomeLayout({
|
|
|
171
171
|
style={layoutStyle}
|
|
172
172
|
>
|
|
173
173
|
{children}
|
|
174
|
-
{showFooter ? footer ?? <Footer locale={locale}
|
|
174
|
+
{showFooter ? footer ?? <Footer locale={locale} localePrefixAsNeeded={localePrefixAsNeeded} defaultLocale={defaultLocale} /> : null}
|
|
175
175
|
{showGoToTop ? goToTop ?? <GoToTop /> : null}
|
|
176
176
|
</HomeLayout>
|
|
177
177
|
</>
|
|
@@ -54,7 +54,7 @@ interface FumaPageParams {
|
|
|
54
54
|
/*
|
|
55
55
|
* Whether localePrefix is set to 'as-needed' (default: true)
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
localePrefixAsNeeded?: boolean;
|
|
58
58
|
|
|
59
59
|
/*
|
|
60
60
|
* The default locale for the application (default: 'en')
|
|
@@ -75,7 +75,7 @@ export function createFumaPage({
|
|
|
75
75
|
showBreadcrumb = true,
|
|
76
76
|
showTableOfContent = true,
|
|
77
77
|
showTableOfContentPopover = false,
|
|
78
|
-
|
|
78
|
+
localePrefixAsNeeded = true,
|
|
79
79
|
defaultLocale = 'en',
|
|
80
80
|
}: FumaPageParams) {
|
|
81
81
|
const Page = async function Page({ params }: { params: Promise<{ locale: string; slug?: string[] }> }) {
|
|
@@ -143,14 +143,14 @@ export function createFumaPage({
|
|
|
143
143
|
const baseRoute = mdxSourceDir.replace('src/mdx/', '');
|
|
144
144
|
// build the current page path
|
|
145
145
|
const currentPath = slug ? slug.join('/') : '';
|
|
146
|
-
const localizedPath = getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`,
|
|
146
|
+
const localizedPath = getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
|
|
147
147
|
const currentUrl = `${baseUrl}${localizedPath}`;
|
|
148
148
|
|
|
149
149
|
// generate the seo language map
|
|
150
150
|
const seoLanguageMap: Record<string, string> = {};
|
|
151
151
|
|
|
152
152
|
supportedLocales.forEach(loc => {
|
|
153
|
-
const seoPath = getAsNeededLocalizedUrl(loc, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`,
|
|
153
|
+
const seoPath = getAsNeededLocalizedUrl(loc, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
|
|
154
154
|
seoLanguageMap[loc] = `${baseUrl}${seoPath}`;
|
|
155
155
|
});
|
|
156
156
|
|
package/src/lib/seo-util.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function generateRobots(baseUrl: string): MetadataRoute.Robots {
|
|
|
34
34
|
* @param locales - Supported locales array
|
|
35
35
|
* @param mdxSourceDir - MDX source directory path
|
|
36
36
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
37
|
-
* @param
|
|
37
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
38
38
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
39
39
|
* @returns Sitemap entries
|
|
40
40
|
*/
|
|
@@ -43,7 +43,7 @@ export function generateSitemap(
|
|
|
43
43
|
locales: string[],
|
|
44
44
|
mdxSourceDir: string,
|
|
45
45
|
openMdxSEOSiteMap: boolean = true,
|
|
46
|
-
|
|
46
|
+
localePrefixAsNeeded: boolean = true,
|
|
47
47
|
defaultLocale: string = 'en'
|
|
48
48
|
): MetadataRoute.Sitemap {
|
|
49
49
|
// 2. handle index.mdx (blog start page) and other slugs
|
|
@@ -61,7 +61,7 @@ export function generateSitemap(
|
|
|
61
61
|
for (const locale of locales) {
|
|
62
62
|
for (const f of blogFiles) {
|
|
63
63
|
if (f === 'index.mdx') {
|
|
64
|
-
const localizedPath = getAsNeededLocalizedUrl(locale, '/blog',
|
|
64
|
+
const localizedPath = getAsNeededLocalizedUrl(locale, '/blog', localePrefixAsNeeded, defaultLocale);
|
|
65
65
|
blogRoutes.push({
|
|
66
66
|
url: `${baseUrl}${localizedPath}`,
|
|
67
67
|
lastModified: new Date(),
|
|
@@ -70,7 +70,7 @@ export function generateSitemap(
|
|
|
70
70
|
});
|
|
71
71
|
} else {
|
|
72
72
|
const slug = f.replace(/\.mdx$/, '');
|
|
73
|
-
const localizedPath = getAsNeededLocalizedUrl(locale, `/blog/${slug}`,
|
|
73
|
+
const localizedPath = getAsNeededLocalizedUrl(locale, `/blog/${slug}`, localePrefixAsNeeded, defaultLocale);
|
|
74
74
|
blogRoutes.push({
|
|
75
75
|
url: `${baseUrl}${localizedPath}`,
|
|
76
76
|
lastModified: new Date(),
|
|
@@ -89,7 +89,7 @@ export function generateSitemap(
|
|
|
89
89
|
|
|
90
90
|
// 3. main page (all language versions)
|
|
91
91
|
const mainRoutes = locales.map(locale => {
|
|
92
|
-
const localizedPath = getAsNeededLocalizedUrl(locale, '/',
|
|
92
|
+
const localizedPath = getAsNeededLocalizedUrl(locale, '/', localePrefixAsNeeded, defaultLocale);
|
|
93
93
|
return {
|
|
94
94
|
url: `${baseUrl}${localizedPath}`,
|
|
95
95
|
lastModified: new Date(),
|
|
@@ -118,7 +118,7 @@ export function createRobotsHandler(baseUrl: string) {
|
|
|
118
118
|
* @param locales - Supported locales array
|
|
119
119
|
* @param mdxSourceDir - MDX source directory path, default is empty
|
|
120
120
|
* @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
|
|
121
|
-
* @param
|
|
121
|
+
* @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
|
|
122
122
|
* @param defaultLocale - The default locale for the application (default: 'en')
|
|
123
123
|
* @returns Sitemap handler function
|
|
124
124
|
*/
|
|
@@ -127,12 +127,12 @@ export function createSitemapHandler(
|
|
|
127
127
|
locales: string[],
|
|
128
128
|
mdxSourceDir: string = '',
|
|
129
129
|
openMdxSEOSiteMap: boolean = true,
|
|
130
|
-
|
|
130
|
+
localePrefixAsNeeded: boolean = true,
|
|
131
131
|
defaultLocale: string = 'en'
|
|
132
132
|
) {
|
|
133
133
|
// force static generation
|
|
134
134
|
const sitemapHandler = function sitemap(): MetadataRoute.Sitemap {
|
|
135
|
-
return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap,
|
|
135
|
+
return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap, localePrefixAsNeeded, defaultLocale);
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
// Add static generation directive
|
package/src/main/footer.tsx
CHANGED
|
@@ -18,11 +18,11 @@ interface FooterData {
|
|
|
18
18
|
|
|
19
19
|
interface FooterProps {
|
|
20
20
|
locale: string;
|
|
21
|
-
|
|
21
|
+
localePrefixAsNeeded?: boolean;
|
|
22
22
|
defaultLocale?: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export async function Footer({ locale,
|
|
25
|
+
export async function Footer({ locale, localePrefixAsNeeded = true, defaultLocale = 'en' }: FooterProps) {
|
|
26
26
|
const tFooter = await getTranslations({ locale, namespace: 'footer' });
|
|
27
27
|
|
|
28
28
|
const company = safeT(tFooter, 'company', '');
|
|
@@ -43,11 +43,11 @@ export async function Footer({ locale, localPrefixAsNeeded = true, defaultLocale
|
|
|
43
43
|
<footer>
|
|
44
44
|
<div className="w-full flex flex-col items-center justify-center px-4 py-8 space-y-3">
|
|
45
45
|
<div className="flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-xs sm:text-sm sm:gap-x-6">
|
|
46
|
-
<Link href={getAsNeededLocalizedUrl(locale, "/legal/terms",
|
|
46
|
+
<Link href={getAsNeededLocalizedUrl(locale, "/legal/terms", localePrefixAsNeeded, defaultLocale)} className="flex items-center space-x-1 hover:underline">
|
|
47
47
|
<icons.ReceiptText className="h-3.5 w-3.5"/>
|
|
48
48
|
<span>{data.terms}</span>
|
|
49
49
|
</Link>
|
|
50
|
-
<Link href={getAsNeededLocalizedUrl(locale, "/legal/privacy",
|
|
50
|
+
<Link href={getAsNeededLocalizedUrl(locale, "/legal/privacy", localePrefixAsNeeded, defaultLocale)} className="flex items-center space-x-1 hover:underline">
|
|
51
51
|
<icons.ShieldUser className="h-3.5 w-3.5"/>
|
|
52
52
|
<span>{data.privacy}</span>
|
|
53
53
|
</Link>
|