@windrun-huaiin/third-ui 5.12.4 → 5.13.1

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.
@@ -4455,7 +4455,7 @@ declare function generateRobots(baseUrl: string): MetadataRoute.Robots;
4455
4455
  * @param baseUrl - The base URL of the website
4456
4456
  * @param locales - Supported locales array
4457
4457
  * @param mdxSourceDir - MDX source directory path
4458
- * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap
4458
+ * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
4459
4459
  * @returns Sitemap entries
4460
4460
  */
4461
4461
  declare function generateSitemap(baseUrl: string, locales: string[], mdxSourceDir: string, openMdxSEOSiteMap?: boolean): MetadataRoute.Sitemap;
@@ -4470,7 +4470,7 @@ declare function createRobotsHandler(baseUrl: string): () => MetadataRoute.Robot
4470
4470
  * @param baseUrl - The base URL of the website
4471
4471
  * @param locales - Supported locales array
4472
4472
  * @param mdxSourceDir - MDX source directory path
4473
- * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap
4473
+ * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
4474
4474
  * @returns Sitemap handler function
4475
4475
  */
4476
4476
  declare function createSitemapHandler(baseUrl: string, locales: string[], mdxSourceDir: string, openMdxSEOSiteMap?: boolean): () => MetadataRoute.Sitemap;
@@ -4455,7 +4455,7 @@ declare function generateRobots(baseUrl: string): MetadataRoute.Robots;
4455
4455
  * @param baseUrl - The base URL of the website
4456
4456
  * @param locales - Supported locales array
4457
4457
  * @param mdxSourceDir - MDX source directory path
4458
- * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap
4458
+ * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
4459
4459
  * @returns Sitemap entries
4460
4460
  */
4461
4461
  declare function generateSitemap(baseUrl: string, locales: string[], mdxSourceDir: string, openMdxSEOSiteMap?: boolean): MetadataRoute.Sitemap;
@@ -4470,7 +4470,7 @@ declare function createRobotsHandler(baseUrl: string): () => MetadataRoute.Robot
4470
4470
  * @param baseUrl - The base URL of the website
4471
4471
  * @param locales - Supported locales array
4472
4472
  * @param mdxSourceDir - MDX source directory path
4473
- * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap
4473
+ * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
4474
4474
  * @returns Sitemap handler function
4475
4475
  */
4476
4476
  declare function createSitemapHandler(baseUrl: string, locales: string[], mdxSourceDir: string, openMdxSEOSiteMap?: boolean): () => MetadataRoute.Sitemap;
@@ -138,28 +138,36 @@ function generateRobots(baseUrl) {
138
138
  sitemap: `${baseUrl}/sitemap.xml`
139
139
  };
140
140
  }
141
- function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = false) {
142
- const blogDir = import_path.default.join(process.cwd(), mdxSourceDir);
143
- const blogFiles = import_fs.default.readdirSync(blogDir).filter((f) => f.endsWith(".mdx"));
141
+ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true) {
144
142
  const blogRoutes = [];
145
- for (const locale of locales) {
146
- for (const f of blogFiles) {
147
- if (f === "index.mdx") {
148
- blogRoutes.push({
149
- url: `${baseUrl}/${locale}/blog`,
150
- lastModified: /* @__PURE__ */ new Date(),
151
- changeFrequency: "daily",
152
- priority: 1
153
- });
154
- } else {
155
- const slug = f.replace(/\.mdx$/, "");
156
- blogRoutes.push({
157
- url: `${baseUrl}/${locale}/blog/${slug}`,
158
- lastModified: /* @__PURE__ */ new Date(),
159
- changeFrequency: f === "ioc.mdx" ? "daily" : "monthly",
160
- priority: 0.8
161
- });
143
+ if (mdxSourceDir && mdxSourceDir.trim() !== "") {
144
+ const blogDir = import_path.default.join(process.cwd(), mdxSourceDir);
145
+ try {
146
+ if (import_fs.default.existsSync(blogDir) && import_fs.default.statSync(blogDir).isDirectory()) {
147
+ const blogFiles = import_fs.default.readdirSync(blogDir).filter((f) => f.endsWith(".mdx"));
148
+ for (const locale of locales) {
149
+ for (const f of blogFiles) {
150
+ if (f === "index.mdx") {
151
+ blogRoutes.push({
152
+ url: `${baseUrl}/${locale}/blog`,
153
+ lastModified: /* @__PURE__ */ new Date(),
154
+ changeFrequency: "daily",
155
+ priority: 1
156
+ });
157
+ } else {
158
+ const slug = f.replace(/\.mdx$/, "");
159
+ blogRoutes.push({
160
+ url: `${baseUrl}/${locale}/blog/${slug}`,
161
+ lastModified: /* @__PURE__ */ new Date(),
162
+ changeFrequency: f === "ioc.mdx" ? "daily" : "monthly",
163
+ priority: 0.8
164
+ });
165
+ }
166
+ }
167
+ }
162
168
  }
169
+ } catch (error) {
170
+ console.warn(`Warning: Could not read MDX directory "${mdxSourceDir}":`, error);
163
171
  }
164
172
  }
165
173
  const mainRoutes = locales.map((locale) => ({
@@ -175,7 +183,7 @@ function createRobotsHandler(baseUrl) {
175
183
  return generateRobots(baseUrl);
176
184
  };
177
185
  }
178
- function createSitemapHandler(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = false) {
186
+ function createSitemapHandler(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true) {
179
187
  const sitemapHandler = function sitemap() {
180
188
  return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap);
181
189
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/server.ts","../../src/lib/fuma-search-util.ts","../../src/lib/clerk-intl.ts","../../src/lib/fuma-schema-check-util.ts","../../src/lib/seo-util.ts"],"sourcesContent":["// This is a server component!\n\nexport * from './fuma-search-util';\nexport * from './clerk-intl';\nexport * from './fuma-schema-check-util';\nexport * from './seo-util';","import { Translations } from 'fumadocs-ui/i18n';\n\nexport const fumaI18nCn: Partial<Translations> = {\n search: 'Translated Content',\n // other translations\n};\n","import { enUS, zhCN } from '@clerk/localizations';\nimport type { LocalizationResource } from '@clerk/types';\n\n// https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts#L492\n// https://clerk.com/docs/customization/localization\nconst customZH: LocalizationResource = {\n ...zhCN,\n}\n\nexport const clerkIntl = {\n en: enUS,\n zh: customZH,\n}","import { z } from 'zod';\nimport { frontmatterSchema, metaSchema } from 'fumadocs-mdx/config';\n\n\n// Reusable schema for title\nexport const createTitleSchema = () =>\n z.string({\n required_error: \"Title is required\",\n invalid_type_error: \"Title must be a string and cannot be null\",\n })\n .trim()\n .min(1, { message: \"Title cannot be empty or consist only of whitespace\" });\n\n// Reusable schema for description\nexport const createDescriptionSchema = () =>\n z.preprocess(\n (val: any) => {\n if (typeof val === 'string') {\n return val.trim() === \"\" || val === null ? undefined : val.trim();\n }\n return val === null ? undefined : val;\n },\n z.string().optional()\n );\n\n// Reusable schema for icon\nexport const createIconSchema = () =>\n z.preprocess(\n (val: any) => (val === \"\" || val === null ? undefined : val),\n z.string().optional()\n );\n\n// Reusable schema for date\nexport const createDateSchema = () =>\n z.preprocess((arg: any) => {\n if (arg instanceof Date) {\n // Format Date object to YYYY-MM-DD string\n const year = arg.getFullYear();\n const month = (arg.getMonth() + 1).toString().padStart(2, '0');\n const day = arg.getDate().toString().padStart(2, '0');\n return `${year}-${month}-${day}`;\n }\n if (typeof arg === 'string') {\n return arg.trim();\n }\n // For other types or null/undefined, let the subsequent string validation handle it\n return arg; \n },\n z.string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Date must be in YYYY-MM-DD format or a valid Date object\")\n .refine((val: any) => !isNaN(new Date(val).getTime()), 'Invalid date!')\n );\n\n// common docs frontmatter schema\nexport const createCommonDocsSchema = () => frontmatterSchema.extend({\n title: createTitleSchema(),\n description: createDescriptionSchema(),\n icon: createIconSchema(),\n date: createDateSchema(),\n author: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n});\n\n// common meta schema\nexport const createCommonMetaSchema = () => metaSchema.extend({\n description: z.string().optional(),\n});\n\nexport const remarkInstallOptions = {\n persist: {\n id: 'package-manager',\n },\n};","import type { MetadataRoute } from 'next';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * Generate robots.txt content\n * @param baseUrl - The base URL of the website\n * @returns Robots configuration\n */\nexport function generateRobots(baseUrl: string): MetadataRoute.Robots {\n return {\n rules: {\n userAgent: \"*\",\n allow: \"/\",\n },\n sitemap: `${baseUrl}/sitemap.xml`,\n };\n}\n\n/**\n * Generate sitemap.xml content\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap\n * @returns Sitemap entries\n */\nexport function generateSitemap(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = false\n): MetadataRoute.Sitemap {\n // 1. read all blog mdx file names\n const blogDir = path.join(process.cwd(), mdxSourceDir);\n const blogFiles = fs.readdirSync(blogDir).filter(f => f.endsWith('.mdx'));\n\n // 2. handle index.mdx (blog start page) and other slugs\n const blogRoutes: MetadataRoute.Sitemap = [];\n\n for (const locale of locales) {\n for (const f of blogFiles) {\n if (f === 'index.mdx') {\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog`,\n lastModified: new Date(),\n changeFrequency: 'daily',\n priority: 1.0\n });\n } else {\n const slug = f.replace(/\\.mdx$/, '');\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog/${slug}`,\n lastModified: new Date(),\n changeFrequency: f === 'ioc.mdx' ? 'daily' : 'monthly',\n priority: 0.8\n });\n }\n }\n }\n\n // 3. main page (all language versions)\n const mainRoutes = locales.map(locale => ({\n url: `${baseUrl}/${locale}`,\n lastModified: new Date(),\n changeFrequency: 'weekly' as const,\n priority: 1.0\n }));\n\n return openMdxSEOSiteMap ? [...mainRoutes, ...blogRoutes] : [...mainRoutes];\n}\n\n/**\n * Create robots.txt handler function\n * @param baseUrl - The base URL of the website\n * @returns Robots handler function\n */\nexport function createRobotsHandler(baseUrl: string) {\n return function robots(): MetadataRoute.Robots {\n return generateRobots(baseUrl);\n };\n}\n\n/**\n * Create sitemap.xml handler function\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap\n * @returns Sitemap handler function\n */\nexport function createSitemapHandler(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = false\n) {\n // force static generation\n const sitemapHandler = function sitemap(): MetadataRoute.Sitemap {\n return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap);\n };\n \n // Add static generation directive\n (sitemapHandler as any).dynamic = 'force-static';\n \n return sitemapHandler;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,aAAoC;AAAA,EAC/C,QAAQ;AAAA;AAEV;;;ACLA,2BAA2B;AAK3B,IAAM,WAAiC,mBAClC;AAGE,IAAM,YAAY;AAAA,EACvB,IAAI;AAAA,EACJ,IAAI;AACN;;;ACZA,iBAAkB;AAClB,oBAA8C;AAIvC,IAAM,oBAAoB,MAC/B,aAAE,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,oBAAoB;AACtB,CAAC,EACA,KAAK,EACL,IAAI,GAAG,EAAE,SAAS,sDAAsD,CAAC;AAGrE,IAAM,0BAA0B,MACrC,aAAE;AAAA,EACA,CAAC,QAAa;AACZ,QAAI,OAAO,QAAQ,UAAU;AAC3B,aAAO,IAAI,KAAK,MAAM,MAAM,QAAQ,OAAO,SAAY,IAAI,KAAK;AAAA,IAClE;AACA,WAAO,QAAQ,OAAO,SAAY;AAAA,EACpC;AAAA,EACA,aAAE,OAAO,EAAE,SAAS;AACtB;AAGK,IAAM,mBAAmB,MAC9B,aAAE;AAAA,EACA,CAAC,QAAc,QAAQ,MAAM,QAAQ,OAAO,SAAY;AAAA,EACxD,aAAE,OAAO,EAAE,SAAS;AACtB;AAGK,IAAM,mBAAmB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ts","../../src/lib/fuma-schema-check-util.ts","../../src/lib/seo-util.ts"],"sourcesContent":["// This is a server component!\n\nexport * from './fuma-search-util';\nexport * from './clerk-intl';\nexport * from './fuma-schema-check-util';\nexport * from './seo-util';","import { Translations } from 'fumadocs-ui/i18n';\n\nexport const fumaI18nCn: Partial<Translations> = {\n search: 'Translated Content',\n // other translations\n};\n","import { enUS, zhCN } from '@clerk/localizations';\nimport type { LocalizationResource } from '@clerk/types';\n\n// https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts#L492\n// https://clerk.com/docs/customization/localization\nconst customZH: LocalizationResource = {\n ...zhCN,\n}\n\nexport const clerkIntl = {\n en: enUS,\n zh: customZH,\n}","import { z } from 'zod';\nimport { frontmatterSchema, metaSchema } from 'fumadocs-mdx/config';\n\n\n// Reusable schema for title\nexport const createTitleSchema = () =>\n z.string({\n required_error: \"Title is required\",\n invalid_type_error: \"Title must be a string and cannot be null\",\n })\n .trim()\n .min(1, { message: \"Title cannot be empty or consist only of whitespace\" });\n\n// Reusable schema for description\nexport const createDescriptionSchema = () =>\n z.preprocess(\n (val: any) => {\n if (typeof val === 'string') {\n return val.trim() === \"\" || val === null ? undefined : val.trim();\n }\n return val === null ? undefined : val;\n },\n z.string().optional()\n );\n\n// Reusable schema for icon\nexport const createIconSchema = () =>\n z.preprocess(\n (val: any) => (val === \"\" || val === null ? undefined : val),\n z.string().optional()\n );\n\n// Reusable schema for date\nexport const createDateSchema = () =>\n z.preprocess((arg: any) => {\n if (arg instanceof Date) {\n // Format Date object to YYYY-MM-DD string\n const year = arg.getFullYear();\n const month = (arg.getMonth() + 1).toString().padStart(2, '0');\n const day = arg.getDate().toString().padStart(2, '0');\n return `${year}-${month}-${day}`;\n }\n if (typeof arg === 'string') {\n return arg.trim();\n }\n // For other types or null/undefined, let the subsequent string validation handle it\n return arg; \n },\n z.string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Date must be in YYYY-MM-DD format or a valid Date object\")\n .refine((val: any) => !isNaN(new Date(val).getTime()), 'Invalid date!')\n );\n\n// common docs frontmatter schema\nexport const createCommonDocsSchema = () => frontmatterSchema.extend({\n title: createTitleSchema(),\n description: createDescriptionSchema(),\n icon: createIconSchema(),\n date: createDateSchema(),\n author: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n});\n\n// common meta schema\nexport const createCommonMetaSchema = () => metaSchema.extend({\n description: z.string().optional(),\n});\n\nexport const remarkInstallOptions = {\n persist: {\n id: 'package-manager',\n },\n};","import type { MetadataRoute } from 'next';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * Generate robots.txt content\n * @param baseUrl - The base URL of the website\n * @returns Robots configuration\n */\nexport function generateRobots(baseUrl: string): MetadataRoute.Robots {\n return {\n rules: {\n userAgent: \"*\",\n allow: \"/\",\n },\n sitemap: `${baseUrl}/sitemap.xml`,\n };\n}\n\n/**\n * Generate sitemap.xml content\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true\n * @returns Sitemap entries\n */\nexport function generateSitemap(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = true\n): MetadataRoute.Sitemap {\n // 2. handle index.mdx (blog start page) and other slugs\n const blogRoutes: MetadataRoute.Sitemap = [];\n\n // 1. read all blog mdx file names with error handling\n if (mdxSourceDir && mdxSourceDir.trim() !== '') {\n const blogDir = path.join(process.cwd(), mdxSourceDir);\n \n // Check if directory exists and is readable\n try {\n if (fs.existsSync(blogDir) && fs.statSync(blogDir).isDirectory()) {\n const blogFiles = fs.readdirSync(blogDir).filter(f => f.endsWith('.mdx'));\n\n for (const locale of locales) {\n for (const f of blogFiles) {\n if (f === 'index.mdx') {\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog`,\n lastModified: new Date(),\n changeFrequency: 'daily',\n priority: 1.0\n });\n } else {\n const slug = f.replace(/\\.mdx$/, '');\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog/${slug}`,\n lastModified: new Date(),\n changeFrequency: f === 'ioc.mdx' ? 'daily' : 'monthly',\n priority: 0.8\n });\n }\n }\n }\n }\n } catch (error) {\n // Handle edge cases like race conditions, permission changes, or filesystem errors\n console.warn(`Warning: Could not read MDX directory \"${mdxSourceDir}\":`, error);\n }\n }\n\n // 3. main page (all language versions)\n const mainRoutes = locales.map(locale => ({\n url: `${baseUrl}/${locale}`,\n lastModified: new Date(),\n changeFrequency: 'weekly' as const,\n priority: 1.0\n }));\n\n return openMdxSEOSiteMap ? [...mainRoutes, ...blogRoutes] : [...mainRoutes];\n}\n\n/**\n * Create robots.txt handler function\n * @param baseUrl - The base URL of the website\n * @returns Robots handler function\n */\nexport function createRobotsHandler(baseUrl: string) {\n return function robots(): MetadataRoute.Robots {\n return generateRobots(baseUrl);\n };\n}\n\n/**\n * Create sitemap.xml handler function\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true\n * @returns Sitemap handler function\n */\nexport function createSitemapHandler(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = true\n) {\n // force static generation\n const sitemapHandler = function sitemap(): MetadataRoute.Sitemap {\n return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap);\n };\n \n // Add static generation directive\n (sitemapHandler as any).dynamic = 'force-static';\n \n return sitemapHandler;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,aAAoC;AAAA,EAC/C,QAAQ;AAAA;AAEV;;;ACLA,2BAA2B;AAK3B,IAAM,WAAiC,mBAClC;AAGE,IAAM,YAAY;AAAA,EACvB,IA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AI;AAAA,gBACtC,cAAc,oBAAI,KAAK;AAAA,gBACvB,iBAAiB,MAAM,YAAY,UAAU;AAAA,gBAC7C,UAAU;AAAA,cACZ,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AAEd,cAAQ,KAAK,0CAA0C,YAAY,MAAM,KAAK;AAAA,IAChF;AAAA,EACF;AAGA,QAAM,aAAa,QAAQ,IAAI,aAAW;AAAA,IACxC,KAAK,GAAG,OAAO,IAAI,MAAM;AAAA,IACzB,cAAc,oBAAI,KAAK;AAAA,IACvB,iBAAiB;AAAA,IACjB,UAAU;AAAA,EACZ,EAAE;AAEF,SAAO,oBAAoB,CAAC,GAAG,YAAY,GAAG,UAAU,IAAI,CAAC,GAAG,UAAU;AAC5E;AAOO,SAAS,oBAAoB,SAAiB;AACnD,SAAO,SAAS,SAA+B;AAC7C,WAAO,eAAe,OAAO;AAAA,EAC/B;AACF;AAUO,SAAS,qBACd,SACA,SACA,cACA,oBAA6B,MAC7B;AAEA,QAAM,iBAAiB,SAAS,UAAiC;AAC/D,WAAO,gBAAgB,SAAS,SAAS,cAAc,iBAAiB;AAAA,EAC1E;AAGA,EAAC,eAAuB,UAAU;AAElC,SAAO;AACT;","names":["path","fs"]}
@@ -93,28 +93,36 @@ function generateRobots(baseUrl) {
93
93
  sitemap: `${baseUrl}/sitemap.xml`
94
94
  };
95
95
  }
96
- function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = false) {
97
- const blogDir = path.join(process.cwd(), mdxSourceDir);
98
- const blogFiles = fs.readdirSync(blogDir).filter((f) => f.endsWith(".mdx"));
96
+ function generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true) {
99
97
  const blogRoutes = [];
100
- for (const locale of locales) {
101
- for (const f of blogFiles) {
102
- if (f === "index.mdx") {
103
- blogRoutes.push({
104
- url: `${baseUrl}/${locale}/blog`,
105
- lastModified: /* @__PURE__ */ new Date(),
106
- changeFrequency: "daily",
107
- priority: 1
108
- });
109
- } else {
110
- const slug = f.replace(/\.mdx$/, "");
111
- blogRoutes.push({
112
- url: `${baseUrl}/${locale}/blog/${slug}`,
113
- lastModified: /* @__PURE__ */ new Date(),
114
- changeFrequency: f === "ioc.mdx" ? "daily" : "monthly",
115
- priority: 0.8
116
- });
98
+ if (mdxSourceDir && mdxSourceDir.trim() !== "") {
99
+ const blogDir = path.join(process.cwd(), mdxSourceDir);
100
+ try {
101
+ if (fs.existsSync(blogDir) && fs.statSync(blogDir).isDirectory()) {
102
+ const blogFiles = fs.readdirSync(blogDir).filter((f) => f.endsWith(".mdx"));
103
+ for (const locale of locales) {
104
+ for (const f of blogFiles) {
105
+ if (f === "index.mdx") {
106
+ blogRoutes.push({
107
+ url: `${baseUrl}/${locale}/blog`,
108
+ lastModified: /* @__PURE__ */ new Date(),
109
+ changeFrequency: "daily",
110
+ priority: 1
111
+ });
112
+ } else {
113
+ const slug = f.replace(/\.mdx$/, "");
114
+ blogRoutes.push({
115
+ url: `${baseUrl}/${locale}/blog/${slug}`,
116
+ lastModified: /* @__PURE__ */ new Date(),
117
+ changeFrequency: f === "ioc.mdx" ? "daily" : "monthly",
118
+ priority: 0.8
119
+ });
120
+ }
121
+ }
122
+ }
117
123
  }
124
+ } catch (error) {
125
+ console.warn(`Warning: Could not read MDX directory "${mdxSourceDir}":`, error);
118
126
  }
119
127
  }
120
128
  const mainRoutes = locales.map((locale) => ({
@@ -130,7 +138,7 @@ function createRobotsHandler(baseUrl) {
130
138
  return generateRobots(baseUrl);
131
139
  };
132
140
  }
133
- function createSitemapHandler(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = false) {
141
+ function createSitemapHandler(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap = true) {
134
142
  const sitemapHandler = function sitemap() {
135
143
  return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap);
136
144
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/fuma-search-util.ts","../../src/lib/clerk-intl.ts","../../src/lib/fuma-schema-check-util.ts","../../src/lib/seo-util.ts"],"sourcesContent":["import { Translations } from 'fumadocs-ui/i18n';\n\nexport const fumaI18nCn: Partial<Translations> = {\n search: 'Translated Content',\n // other translations\n};\n","import { enUS, zhCN } from '@clerk/localizations';\nimport type { LocalizationResource } from '@clerk/types';\n\n// https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts#L492\n// https://clerk.com/docs/customization/localization\nconst customZH: LocalizationResource = {\n ...zhCN,\n}\n\nexport const clerkIntl = {\n en: enUS,\n zh: customZH,\n}","import { z } from 'zod';\nimport { frontmatterSchema, metaSchema } from 'fumadocs-mdx/config';\n\n\n// Reusable schema for title\nexport const createTitleSchema = () =>\n z.string({\n required_error: \"Title is required\",\n invalid_type_error: \"Title must be a string and cannot be null\",\n })\n .trim()\n .min(1, { message: \"Title cannot be empty or consist only of whitespace\" });\n\n// Reusable schema for description\nexport const createDescriptionSchema = () =>\n z.preprocess(\n (val: any) => {\n if (typeof val === 'string') {\n return val.trim() === \"\" || val === null ? undefined : val.trim();\n }\n return val === null ? undefined : val;\n },\n z.string().optional()\n );\n\n// Reusable schema for icon\nexport const createIconSchema = () =>\n z.preprocess(\n (val: any) => (val === \"\" || val === null ? undefined : val),\n z.string().optional()\n );\n\n// Reusable schema for date\nexport const createDateSchema = () =>\n z.preprocess((arg: any) => {\n if (arg instanceof Date) {\n // Format Date object to YYYY-MM-DD string\n const year = arg.getFullYear();\n const month = (arg.getMonth() + 1).toString().padStart(2, '0');\n const day = arg.getDate().toString().padStart(2, '0');\n return `${year}-${month}-${day}`;\n }\n if (typeof arg === 'string') {\n return arg.trim();\n }\n // For other types or null/undefined, let the subsequent string validation handle it\n return arg; \n },\n z.string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Date must be in YYYY-MM-DD format or a valid Date object\")\n .refine((val: any) => !isNaN(new Date(val).getTime()), 'Invalid date!')\n );\n\n// common docs frontmatter schema\nexport const createCommonDocsSchema = () => frontmatterSchema.extend({\n title: createTitleSchema(),\n description: createDescriptionSchema(),\n icon: createIconSchema(),\n date: createDateSchema(),\n author: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n});\n\n// common meta schema\nexport const createCommonMetaSchema = () => metaSchema.extend({\n description: z.string().optional(),\n});\n\nexport const remarkInstallOptions = {\n persist: {\n id: 'package-manager',\n },\n};","import type { MetadataRoute } from 'next';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * Generate robots.txt content\n * @param baseUrl - The base URL of the website\n * @returns Robots configuration\n */\nexport function generateRobots(baseUrl: string): MetadataRoute.Robots {\n return {\n rules: {\n userAgent: \"*\",\n allow: \"/\",\n },\n sitemap: `${baseUrl}/sitemap.xml`,\n };\n}\n\n/**\n * Generate sitemap.xml content\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap\n * @returns Sitemap entries\n */\nexport function generateSitemap(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = false\n): MetadataRoute.Sitemap {\n // 1. read all blog mdx file names\n const blogDir = path.join(process.cwd(), mdxSourceDir);\n const blogFiles = fs.readdirSync(blogDir).filter(f => f.endsWith('.mdx'));\n\n // 2. handle index.mdx (blog start page) and other slugs\n const blogRoutes: MetadataRoute.Sitemap = [];\n\n for (const locale of locales) {\n for (const f of blogFiles) {\n if (f === 'index.mdx') {\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog`,\n lastModified: new Date(),\n changeFrequency: 'daily',\n priority: 1.0\n });\n } else {\n const slug = f.replace(/\\.mdx$/, '');\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog/${slug}`,\n lastModified: new Date(),\n changeFrequency: f === 'ioc.mdx' ? 'daily' : 'monthly',\n priority: 0.8\n });\n }\n }\n }\n\n // 3. main page (all language versions)\n const mainRoutes = locales.map(locale => ({\n url: `${baseUrl}/${locale}`,\n lastModified: new Date(),\n changeFrequency: 'weekly' as const,\n priority: 1.0\n }));\n\n return openMdxSEOSiteMap ? [...mainRoutes, ...blogRoutes] : [...mainRoutes];\n}\n\n/**\n * Create robots.txt handler function\n * @param baseUrl - The base URL of the website\n * @returns Robots handler function\n */\nexport function createRobotsHandler(baseUrl: string) {\n return function robots(): MetadataRoute.Robots {\n return generateRobots(baseUrl);\n };\n}\n\n/**\n * Create sitemap.xml handler function\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap\n * @returns Sitemap handler function\n */\nexport function createSitemapHandler(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = false\n) {\n // force static generation\n const sitemapHandler = function sitemap(): MetadataRoute.Sitemap {\n return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap);\n };\n \n // Add static generation directive\n (sitemapHandler as any).dynamic = 'force-static';\n \n return sitemapHandler;\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAEO,IAAM,aAAoC;AAAA,EAC/C,QAAQ;AAAA;AAEV;;;ACLA,SAAS,MAAM,YAAY;AAK3B,IAAM,WAAiC,mBAClC;AAGE,IAAM,YAAY;AAAA,EACvB,IAAI;AAAA,EACJ,IAAI;AACN;;;ACZA,SAAS,SAAS;AAClB,SAAS,mBAAmB,kBAAkB;AAIvC,IAAM,oBAAoB,MAC/B,EAAE,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,oBAAoB;AACtB,CAAC,EACA,KAAK,EACL,IAAI,GAAG,EAAE,SAAS,sDAAsD,CAAC;AAGrE,IAAM,0BAA0B,MACrC,EAAE;AAAA,EACA,CAAC,QAAa;AACZ,QAAI,OAAO,QAAQ,UAAU;AAC3B,aAAO,IAAI,KAAK,MAAM,MAAM,QAAQ,OAAO,SAAY,IAAI,KAAK;AAAA,IAClE;AACA,WAAO,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AAM,iBAAiB,SAAS,UAAiC;AAC/D,WAAO,gBAAgB,SAAS,SAAS,cAAc,iBAAiB;AAAA,EAC1E;AAGA,EAAC,eAAuB,UAAU;AAElC,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/fuma-search-util.ts","../../src/lib/clerk-intl.ts","../../src/lib/fuma-schema-check-util.ts","../../src/lib/seo-util.ts"],"sourcesContent":["import { Translations } from 'fumadocs-ui/i18n';\n\nexport const fumaI18nCn: Partial<Translations> = {\n search: 'Translated Content',\n // other translations\n};\n","import { enUS, zhCN } from '@clerk/localizations';\nimport type { LocalizationResource } from '@clerk/types';\n\n// https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts#L492\n// https://clerk.com/docs/customization/localization\nconst customZH: LocalizationResource = {\n ...zhCN,\n}\n\nexport const clerkIntl = {\n en: enUS,\n zh: customZH,\n}","import { z } from 'zod';\nimport { frontmatterSchema, metaSchema } from 'fumadocs-mdx/config';\n\n\n// Reusable schema for title\nexport const createTitleSchema = () =>\n z.string({\n required_error: \"Title is required\",\n invalid_type_error: \"Title must be a string and cannot be null\",\n })\n .trim()\n .min(1, { message: \"Title cannot be empty or consist only of whitespace\" });\n\n// Reusable schema for description\nexport const createDescriptionSchema = () =>\n z.preprocess(\n (val: any) => {\n if (typeof val === 'string') {\n return val.trim() === \"\" || val === null ? undefined : val.trim();\n }\n return val === null ? undefined : val;\n },\n z.string().optional()\n );\n\n// Reusable schema for icon\nexport const createIconSchema = () =>\n z.preprocess(\n (val: any) => (val === \"\" || val === null ? undefined : val),\n z.string().optional()\n );\n\n// Reusable schema for date\nexport const createDateSchema = () =>\n z.preprocess((arg: any) => {\n if (arg instanceof Date) {\n // Format Date object to YYYY-MM-DD string\n const year = arg.getFullYear();\n const month = (arg.getMonth() + 1).toString().padStart(2, '0');\n const day = arg.getDate().toString().padStart(2, '0');\n return `${year}-${month}-${day}`;\n }\n if (typeof arg === 'string') {\n return arg.trim();\n }\n // For other types or null/undefined, let the subsequent string validation handle it\n return arg; \n },\n z.string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Date must be in YYYY-MM-DD format or a valid Date object\")\n .refine((val: any) => !isNaN(new Date(val).getTime()), 'Invalid date!')\n );\n\n// common docs frontmatter schema\nexport const createCommonDocsSchema = () => frontmatterSchema.extend({\n title: createTitleSchema(),\n description: createDescriptionSchema(),\n icon: createIconSchema(),\n date: createDateSchema(),\n author: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n});\n\n// common meta schema\nexport const createCommonMetaSchema = () => metaSchema.extend({\n description: z.string().optional(),\n});\n\nexport const remarkInstallOptions = {\n persist: {\n id: 'package-manager',\n },\n};","import type { MetadataRoute } from 'next';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * Generate robots.txt content\n * @param baseUrl - The base URL of the website\n * @returns Robots configuration\n */\nexport function generateRobots(baseUrl: string): MetadataRoute.Robots {\n return {\n rules: {\n userAgent: \"*\",\n allow: \"/\",\n },\n sitemap: `${baseUrl}/sitemap.xml`,\n };\n}\n\n/**\n * Generate sitemap.xml content\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true\n * @returns Sitemap entries\n */\nexport function generateSitemap(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = true\n): MetadataRoute.Sitemap {\n // 2. handle index.mdx (blog start page) and other slugs\n const blogRoutes: MetadataRoute.Sitemap = [];\n\n // 1. read all blog mdx file names with error handling\n if (mdxSourceDir && mdxSourceDir.trim() !== '') {\n const blogDir = path.join(process.cwd(), mdxSourceDir);\n \n // Check if directory exists and is readable\n try {\n if (fs.existsSync(blogDir) && fs.statSync(blogDir).isDirectory()) {\n const blogFiles = fs.readdirSync(blogDir).filter(f => f.endsWith('.mdx'));\n\n for (const locale of locales) {\n for (const f of blogFiles) {\n if (f === 'index.mdx') {\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog`,\n lastModified: new Date(),\n changeFrequency: 'daily',\n priority: 1.0\n });\n } else {\n const slug = f.replace(/\\.mdx$/, '');\n blogRoutes.push({\n url: `${baseUrl}/${locale}/blog/${slug}`,\n lastModified: new Date(),\n changeFrequency: f === 'ioc.mdx' ? 'daily' : 'monthly',\n priority: 0.8\n });\n }\n }\n }\n }\n } catch (error) {\n // Handle edge cases like race conditions, permission changes, or filesystem errors\n console.warn(`Warning: Could not read MDX directory \"${mdxSourceDir}\":`, error);\n }\n }\n\n // 3. main page (all language versions)\n const mainRoutes = locales.map(locale => ({\n url: `${baseUrl}/${locale}`,\n lastModified: new Date(),\n changeFrequency: 'weekly' as const,\n priority: 1.0\n }));\n\n return openMdxSEOSiteMap ? [...mainRoutes, ...blogRoutes] : [...mainRoutes];\n}\n\n/**\n * Create robots.txt handler function\n * @param baseUrl - The base URL of the website\n * @returns Robots handler function\n */\nexport function createRobotsHandler(baseUrl: string) {\n return function robots(): MetadataRoute.Robots {\n return generateRobots(baseUrl);\n };\n}\n\n/**\n * Create sitemap.xml handler function\n * @param baseUrl - The base URL of the website\n * @param locales - Supported locales array\n * @param mdxSourceDir - MDX source directory path\n * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true\n * @returns Sitemap handler function\n */\nexport function createSitemapHandler(\n baseUrl: string,\n locales: string[],\n mdxSourceDir: string,\n openMdxSEOSiteMap: boolean = true\n) {\n // force static generation\n const sitemapHandler = function sitemap(): MetadataRoute.Sitemap {\n return generateSitemap(baseUrl, locales, mdxSourceDir, openMdxSEOSiteMap);\n };\n \n // Add static generation directive\n (sitemapHandler as any).dynamic = 'force-static';\n \n return sitemapHandler;\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAEO,IAAM,aAAoC;AAAA,EAC/C,QAAQ;AAAA;AAEV;;;ACLA,SAAS,MAAM,YAAY;AAK3B,IAAM,WAAiC,mBAClC;AAGE,IAAM,YAAY;AAAA,EACvB,IAAI;AAAA,EACJ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,cAAc,oBAAI,KAAK;AAAA,gBACvB,iBAAiB,MAAM,YAAY,UAAU;AAAA,gBAC7C,UAAU;AAAA,cACZ,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AAEd,cAAQ,KAAK,0CAA0C,YAAY,MAAM,KAAK;AAAA,IAChF;AAAA,EACF;AAGA,QAAM,aAAa,QAAQ,IAAI,aAAW;AAAA,IACxC,KAAK,GAAG,OAAO,IAAI,MAAM;AAAA,IACzB,cAAc,oBAAI,KAAK;AAAA,IACvB,iBAAiB;AAAA,IACjB,UAAU;AAAA,EACZ,EAAE;AAEF,SAAO,oBAAoB,CAAC,GAAG,YAAY,GAAG,UAAU,IAAI,CAAC,GAAG,UAAU;AAC5E;AAOO,SAAS,oBAAoB,SAAiB;AACnD,SAAO,SAAS,SAA+B;AAC7C,WAAO,eAAe,OAAO;AAAA,EAC/B;AACF;AAUO,SAAS,qBACd,SACA,SACA,cACA,oBAA6B,MAC7B;AAEA,QAAM,iBAAiB,SAAS,UAAiC;AAC/D,WAAO,gBAAgB,SAAS,SAAS,cAAc,iBAAiB;AAAA,EAC1E;AAGA,EAAC,eAAuB,UAAU;AAElC,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "5.12.4",
3
+ "version": "5.13.1",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -22,40 +22,51 @@ export function generateRobots(baseUrl: string): MetadataRoute.Robots {
22
22
  * @param baseUrl - The base URL of the website
23
23
  * @param locales - Supported locales array
24
24
  * @param mdxSourceDir - MDX source directory path
25
- * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap
25
+ * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
26
26
  * @returns Sitemap entries
27
27
  */
28
28
  export function generateSitemap(
29
29
  baseUrl: string,
30
30
  locales: string[],
31
31
  mdxSourceDir: string,
32
- openMdxSEOSiteMap: boolean = false
32
+ openMdxSEOSiteMap: boolean = true
33
33
  ): MetadataRoute.Sitemap {
34
- // 1. read all blog mdx file names
35
- const blogDir = path.join(process.cwd(), mdxSourceDir);
36
- const blogFiles = fs.readdirSync(blogDir).filter(f => f.endsWith('.mdx'));
37
-
38
34
  // 2. handle index.mdx (blog start page) and other slugs
39
35
  const blogRoutes: MetadataRoute.Sitemap = [];
40
36
 
41
- for (const locale of locales) {
42
- for (const f of blogFiles) {
43
- if (f === 'index.mdx') {
44
- blogRoutes.push({
45
- url: `${baseUrl}/${locale}/blog`,
46
- lastModified: new Date(),
47
- changeFrequency: 'daily',
48
- priority: 1.0
49
- });
50
- } else {
51
- const slug = f.replace(/\.mdx$/, '');
52
- blogRoutes.push({
53
- url: `${baseUrl}/${locale}/blog/${slug}`,
54
- lastModified: new Date(),
55
- changeFrequency: f === 'ioc.mdx' ? 'daily' : 'monthly',
56
- priority: 0.8
57
- });
37
+ // 1. read all blog mdx file names with error handling
38
+ if (mdxSourceDir && mdxSourceDir.trim() !== '') {
39
+ const blogDir = path.join(process.cwd(), mdxSourceDir);
40
+
41
+ // Check if directory exists and is readable
42
+ try {
43
+ if (fs.existsSync(blogDir) && fs.statSync(blogDir).isDirectory()) {
44
+ const blogFiles = fs.readdirSync(blogDir).filter(f => f.endsWith('.mdx'));
45
+
46
+ for (const locale of locales) {
47
+ for (const f of blogFiles) {
48
+ if (f === 'index.mdx') {
49
+ blogRoutes.push({
50
+ url: `${baseUrl}/${locale}/blog`,
51
+ lastModified: new Date(),
52
+ changeFrequency: 'daily',
53
+ priority: 1.0
54
+ });
55
+ } else {
56
+ const slug = f.replace(/\.mdx$/, '');
57
+ blogRoutes.push({
58
+ url: `${baseUrl}/${locale}/blog/${slug}`,
59
+ lastModified: new Date(),
60
+ changeFrequency: f === 'ioc.mdx' ? 'daily' : 'monthly',
61
+ priority: 0.8
62
+ });
63
+ }
64
+ }
65
+ }
58
66
  }
67
+ } catch (error) {
68
+ // Handle edge cases like race conditions, permission changes, or filesystem errors
69
+ console.warn(`Warning: Could not read MDX directory "${mdxSourceDir}":`, error);
59
70
  }
60
71
  }
61
72
 
@@ -86,14 +97,14 @@ export function createRobotsHandler(baseUrl: string) {
86
97
  * @param baseUrl - The base URL of the website
87
98
  * @param locales - Supported locales array
88
99
  * @param mdxSourceDir - MDX source directory path
89
- * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap
100
+ * @param openMdxSEOSiteMap - Whether to include MDX content in sitemap, default is true
90
101
  * @returns Sitemap handler function
91
102
  */
92
103
  export function createSitemapHandler(
93
104
  baseUrl: string,
94
105
  locales: string[],
95
106
  mdxSourceDir: string,
96
- openMdxSEOSiteMap: boolean = false
107
+ openMdxSEOSiteMap: boolean = true
97
108
  ) {
98
109
  // force static generation
99
110
  const sitemapHandler = function sitemap(): MetadataRoute.Sitemap {