a90895e167
**1. Shared Lingui factory in `twenty-shared`**
- Extracted `createI18nInstanceFactory` into
`packages/twenty-shared/src/i18n/create-i18n-instance-factory.ts` so
every package gets the same per-render Lingui bootstrap with a
per-locale singleton cache and a `SOURCE_LOCALE` fallback.
- `twenty-emails/src/utils/i18n.utils.ts` now consumes the shared
factory.
**2. `twenty-website-new` Lingui bootstrap + Crowdin wiring**
- `lingui.config.ts`, `src/lib/i18n/*`, `nx run
twenty-website-new:lingui:{extract,compile}`.
- 31 locale PO files generated; minified compiled output kept out of
Prettier and Oxlint.
- `i18n-{push,pull}.yaml` workflows updated to include
`twenty-website-new` in Crowdin sync.
**3. `app/[locale]/...` segment routing with English at the root**
- All marketing routes moved under `src/app/[locale]/`; static
generation preserved (15 routes × 31 locales = 465 prerendered URLs).
- Middleware behavior:
- `/{en}/...` → 301 redirect to unprefixed canonical.
- `/{non-en}/...` → pass through, set `NEXT_LOCALE` cookie.
### What this PR explicitly does not do (deferred)
- Lingui-wrapping the actual marketing copy. Keys, build pipeline, and
runtime are wired; copy migration is a separate, reviewer-friendlier
PR.
167 lines
4.2 KiB
TypeScript
167 lines
4.2 KiB
TypeScript
import path from 'path';
|
|
import withLinaria, { type LinariaConfig } from 'next-with-linaria';
|
|
|
|
const SECURITY_HEADERS = [
|
|
{
|
|
key: 'Strict-Transport-Security',
|
|
value: 'max-age=63072000; includeSubDomains; preload',
|
|
},
|
|
{ key: 'X-Content-Type-Options', value: 'nosniff' },
|
|
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
|
|
{
|
|
key: 'Permissions-Policy',
|
|
value: 'camera=(), microphone=(), geolocation=(), payment=()',
|
|
},
|
|
{ key: 'X-Frame-Options', value: 'DENY' },
|
|
{ key: 'Content-Security-Policy', value: "frame-ancestors 'none'" },
|
|
] as const;
|
|
|
|
const nextConfig: LinariaConfig = {
|
|
images: {
|
|
formats: ['image/avif', 'image/webp'],
|
|
remotePatterns: [
|
|
{
|
|
hostname: 'avatars.githubusercontent.com',
|
|
pathname: '/**',
|
|
protocol: 'https',
|
|
},
|
|
{
|
|
hostname: 'twenty-icons.com',
|
|
pathname: '/**',
|
|
protocol: 'https',
|
|
},
|
|
],
|
|
},
|
|
linaria: {
|
|
configFile: path.resolve(__dirname, 'wyw-in-js.config.cjs'),
|
|
},
|
|
reactCompiler: true,
|
|
experimental: {
|
|
swcPlugins: [
|
|
[
|
|
'@lingui/swc-plugin',
|
|
{
|
|
runtimeModules: {
|
|
i18n: ['@lingui/core', 'i18n'],
|
|
trans: ['@lingui/react', 'Trans'],
|
|
},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: '/:path*',
|
|
headers: SECURITY_HEADERS.map((h) => ({ ...h })),
|
|
},
|
|
];
|
|
},
|
|
async redirects() {
|
|
return [
|
|
{
|
|
source: '/user-guide',
|
|
destination: 'https://docs.twenty.com/user-guide/introduction',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/user-guide/section/:folder/:slug*',
|
|
destination: 'https://docs.twenty.com/user-guide/:folder/:slug*',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/user-guide/:folder/:slug*',
|
|
destination: 'https://docs.twenty.com/user-guide/:folder/:slug*',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/developers',
|
|
destination: 'https://docs.twenty.com/developers/introduction',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/developers/section/:folder/:slug*',
|
|
destination: 'https://docs.twenty.com/developers/:folder/:slug*',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/developers/:folder/:slug*',
|
|
destination: 'https://docs.twenty.com/developers/:folder/:slug*',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/developers/:slug',
|
|
destination: 'https://docs.twenty.com/developers/:slug',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/twenty-ui',
|
|
destination: 'https://docs.twenty.com/twenty-ui/introduction',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/twenty-ui/section/:folder/:slug*',
|
|
destination: 'https://docs.twenty.com/twenty-ui/:folder/:slug*',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/twenty-ui/:folder/:slug*',
|
|
destination: 'https://docs.twenty.com/twenty-ui/:folder/:slug*',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/twenty-ui/:slug',
|
|
destination: 'https://docs.twenty.com/twenty-ui/:slug',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/story',
|
|
destination: '/why-twenty',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/legal/privacy',
|
|
destination: '/privacy-policy',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/legal/terms',
|
|
destination: '/terms',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/legal/dpa',
|
|
destination: '/terms',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/case-studies/9-dots-story',
|
|
destination: '/customers/9dots',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/case-studies/act-immi-story',
|
|
destination: '/customers/act-education',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/case-studies/:slug*',
|
|
destination: '/customers',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/implementation-services',
|
|
destination: '/partners',
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: '/onboarding-packages',
|
|
destination: '/partners',
|
|
permanent: true,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
module.exports = withLinaria(nextConfig);
|