* fix(docs): resolve TypeScript build errors and search configuration Fix invalid LayoutProps type in [lang]/(docs)/layout.tsx to use proper Next.js 16 async layout component signature. Add type assertion in i18n.ts isLocale function to satisfy strict type checking. Configure search to use English indexing since Orama doesn't support Chinese. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * feat(docs): configure static export following Fumadocs guidelines - Enable Next.js static export with output: 'export' - Configure static search using staticGET and revalidate: false - Update search UI to use type: 'static' for client-side search - Add localeMap to support both English and Chinese locales - Remove rewrites (incompatible with static export) - Remove route handlers that conflict with static export: - /llms.mdx route (file extension conflicts) - /llms-full.txt route - /og/docs OG image generation - Add trailingSlash: true for better route handling Build successfully generates 9 static pages (2.7MB total). Search indexes are exported as static files for client-side use. Reference: https://www.fumadocs.dev/docs/deploying/static Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix(docs): resolve 404 issues in static export - Change hideLocale from 'default-locale' to 'never' for static export compatibility (middleware doesn't work in static builds) - Add public/index.html to redirect root path to /en/ - Update middleware matcher to remove deleted route exclusions - All pages now accessible with language prefix (/en/, /zh/) This fixes the 404 issue where middleware-based rewrites don't work in static exports. Now all URLs explicitly include the language code. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * feat(docs): serve English content at root path without redirect - Restore hideLocale to 'default-locale' for cleaner URLs - Add post-export script to copy /en/ content to root directory - English pages now accessible at both / and /en/ - Chinese pages remain at /zh/ - Remove redirect page in favor of direct content serving - Add "type": "module" to package.json for ES modules This provides a better user experience by serving English content directly at the root path (/, /cookies/, /faq/) without requiring a redirect, while maintaining /en/ for explicit access. Output size: 3.2MB (includes both root and /en/ copies) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
47 lines
1.3 KiB
JavaScript
Executable File
47 lines
1.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Post-export script to copy English content to root directory
|
|
* This allows the default language (en) to be accessible without language prefix
|
|
*/
|
|
|
|
import { cpSync, existsSync, mkdirSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
const outDir = join(__dirname, '../out');
|
|
const enDir = join(outDir, 'en');
|
|
|
|
console.log('Copying English content to root directory...');
|
|
|
|
if (!existsSync(enDir)) {
|
|
console.error('Error: /en directory not found in output');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Get all items in /en directory
|
|
const fs = await import('node:fs/promises');
|
|
const items = await fs.readdir(enDir);
|
|
|
|
// Copy each item to root, excluding already existing root items
|
|
for (const item of items) {
|
|
const source = join(enDir, item);
|
|
const dest = join(outDir, item);
|
|
|
|
// Skip if item already exists at root (like _next, api, etc.)
|
|
if (existsSync(dest)) {
|
|
console.log(`Skipping ${item} (already exists at root)`);
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
cpSync(source, dest, { recursive: true });
|
|
console.log(`Copied ${item}`);
|
|
} catch (error) {
|
|
console.error(`Error copying ${item}:`, error.message);
|
|
}
|
|
}
|
|
|
|
console.log('English content copied to root directory successfully!');
|