reroute-js 1.0.0-alpha.4 → 1.0.0-alpha.41
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/README.md +45 -3
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +3229 -1217
- package/cli/bin.js.map +66 -53
- package/cli/index.d.ts +1 -1
- package/cli/index.js +672 -45
- package/cli/index.js.map +57 -7
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts.map +1 -1
- package/cli/src/commands/build.d.ts +6 -3
- package/cli/src/commands/build.d.ts.map +1 -1
- package/cli/src/commands/dev.d.ts +6 -6
- package/cli/src/commands/dev.d.ts.map +1 -1
- package/cli/src/commands/gen.d.ts +4 -1
- package/cli/src/commands/gen.d.ts.map +1 -1
- package/cli/src/commands/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/assets.d.ts +1 -1
- package/cli/src/commands/lib/bundler.d.ts +8 -1
- package/cli/src/commands/lib/bundler.d.ts.map +1 -1
- package/cli/src/commands/lib/command.d.ts +1 -1
- package/cli/src/commands/lib/env.d.ts +4 -3
- package/cli/src/commands/lib/env.d.ts.map +1 -1
- package/cli/src/commands/lib/images.d.ts +12 -0
- package/cli/src/commands/lib/images.d.ts.map +1 -0
- package/cli/src/commands/lib/index.d.ts +1 -1
- package/cli/src/commands/lib/log.d.ts +1 -1
- package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
- package/cli/src/commands/lib/markdown/index.d.ts +1 -1
- package/cli/src/commands/lib/markdown/processor.d.ts +11 -1
- package/cli/src/commands/lib/markdown/processor.d.ts.map +1 -1
- package/cli/src/commands/lib/prerender.d.ts +40 -0
- package/cli/src/commands/lib/prerender.d.ts.map +1 -0
- package/cli/src/commands/lib/production.d.ts +3 -3
- package/cli/src/commands/lib/production.d.ts.map +1 -1
- package/cli/src/commands/lib/routes.d.ts +40 -0
- package/cli/src/commands/lib/routes.d.ts.map +1 -0
- package/cli/src/commands/lib/server.d.ts +2 -1
- package/cli/src/commands/lib/server.d.ts.map +1 -1
- package/cli/src/commands/lib/ssr-strip.d.ts +33 -0
- package/cli/src/commands/lib/ssr-strip.d.ts.map +1 -0
- package/cli/src/commands/lib/static.d.ts +86 -0
- package/cli/src/commands/lib/static.d.ts.map +1 -0
- package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
- package/cli/src/commands/lib/streaming/suspense.d.ts +2 -2
- package/cli/src/commands/lib/streaming/suspense.d.ts.map +1 -1
- package/cli/src/commands/lib/supervise.d.ts +23 -0
- package/cli/src/commands/lib/supervise.d.ts.map +1 -0
- package/cli/src/commands/lib/terminal-ui.d.ts +2 -2
- package/cli/src/commands/lib/terminal-ui.d.ts.map +1 -1
- package/cli/src/commands/lib/theme.d.ts +9 -4
- package/cli/src/commands/lib/theme.d.ts.map +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/lib/watch.d.ts +37 -0
- package/cli/src/commands/lib/watch.d.ts.map +1 -0
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/og.d.ts.map +1 -1
- package/cli/src/commands/start.d.ts +2 -2
- package/cli/src/commands/start.d.ts.map +1 -1
- package/cli/src/commands/static-render.d.ts +18 -0
- package/cli/src/commands/static-render.d.ts.map +1 -0
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +1102 -369
- package/core/index.js.map +40 -37
- package/core/src/app-paths.d.ts +32 -0
- package/core/src/app-paths.d.ts.map +1 -0
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +98 -7
- package/core/src/config.d.ts.map +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/i18n/catalog.d.ts +1 -1
- package/core/src/i18n/discover.d.ts +1 -1
- package/core/src/i18n/discover.d.ts.map +1 -1
- package/core/src/i18n/index.d.ts +2 -2
- package/core/src/i18n/index.d.ts.map +1 -1
- package/core/src/i18n/messages.d.ts +1 -1
- package/core/src/i18n/negotiate.d.ts +1 -1
- package/core/src/i18n/pathname.d.ts +32 -4
- package/core/src/i18n/pathname.d.ts.map +1 -1
- package/core/src/i18n/resolve.d.ts +5 -3
- package/core/src/i18n/resolve.d.ts.map +1 -1
- package/core/src/i18n/types.d.ts +48 -1
- package/core/src/i18n/types.d.ts.map +1 -1
- package/core/src/image.d.ts +29 -0
- package/core/src/image.d.ts.map +1 -0
- package/core/src/index.d.ts +3 -1
- package/core/src/index.d.ts.map +1 -1
- package/core/src/llms/discovery.d.ts +35 -0
- package/core/src/llms/discovery.d.ts.map +1 -0
- package/core/src/llms/extractor.d.ts +6 -1
- package/core/src/llms/extractor.d.ts.map +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/formatter.d.ts.map +1 -1
- package/core/src/llms/full-generator.d.ts +3 -1
- package/core/src/llms/full-generator.d.ts.map +1 -1
- package/core/src/llms/index-generator.d.ts +6 -3
- package/core/src/llms/index-generator.d.ts.map +1 -1
- package/core/src/llms/index.d.ts +5 -2
- package/core/src/llms/index.d.ts.map +1 -1
- package/core/src/og/discovery.d.ts +8 -1
- package/core/src/og/discovery.d.ts.map +1 -1
- package/core/src/og/index.d.ts +1 -1
- package/core/src/og/meta.d.ts +1 -1
- package/core/src/og/render.d.ts +1 -1
- package/core/src/og/types.d.ts +1 -1
- package/core/src/robots/discovery.d.ts +1 -1
- package/core/src/robots/generator.d.ts +1 -1
- package/core/src/robots/generator.d.ts.map +1 -1
- package/core/src/robots/index.d.ts +1 -1
- package/core/src/robots/policies.d.ts +1 -1
- package/core/src/rss/discovery.d.ts +2 -2
- package/core/src/rss/discovery.d.ts.map +1 -1
- package/core/src/rss/generator.d.ts +1 -1
- package/core/src/rss/index.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts +7 -2
- package/core/src/sitemap/discovery.d.ts.map +1 -1
- package/core/src/sitemap/generator.d.ts +12 -2
- package/core/src/sitemap/generator.d.ts.map +1 -1
- package/core/src/sitemap/index.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/lib/cache.d.ts +1 -1
- package/core/src/ssr/lib/cleanup.d.ts +1 -1
- package/core/src/ssr/lib/collections.d.ts +17 -1
- package/core/src/ssr/lib/collections.d.ts.map +1 -1
- package/core/src/ssr/lib/compression.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts.map +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts.map +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts.map +1 -1
- package/core/src/ssr/lib/content-path.d.ts +13 -2
- package/core/src/ssr/lib/content-path.d.ts.map +1 -1
- package/core/src/ssr/lib/data.d.ts +1 -1
- package/core/src/ssr/lib/html.d.ts +7 -1
- package/core/src/ssr/lib/html.d.ts.map +1 -1
- package/core/src/ssr/lib/imports.d.ts +8 -3
- package/core/src/ssr/lib/imports.d.ts.map +1 -1
- package/core/src/ssr/lib/index.d.ts +1 -1
- package/core/src/ssr/lib/layouts.d.ts +15 -2
- package/core/src/ssr/lib/layouts.d.ts.map +1 -1
- package/core/src/ssr/lib/metadata.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts.map +1 -1
- package/core/src/ssr/lib/mime.d.ts +1 -1
- package/core/src/ssr/lib/modules.d.ts +1 -1
- package/core/src/ssr/lib/path.d.ts +1 -1
- package/core/src/ssr/lib/preload.d.ts +16 -3
- package/core/src/ssr/lib/preload.d.ts.map +1 -1
- package/core/src/ssr/lib/route-match.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +2 -2
- package/core/src/ssr/lib/scripts/collections.d.ts.map +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts.map +1 -1
- package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
- package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
- package/core/src/ssr/lib/scripts/index.d.ts +1 -1
- package/core/src/ssr/lib/seed.d.ts +6 -1
- package/core/src/ssr/lib/seed.d.ts.map +1 -1
- package/core/src/ssr/lib/serialize.d.ts +1 -1
- package/core/src/ssr/lib/setup.d.ts +2 -2
- package/core/src/ssr/lib/setup.d.ts.map +1 -1
- package/core/src/ssr/lib/styles.d.ts +5 -4
- package/core/src/ssr/lib/styles.d.ts.map +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +36 -2
- package/core/src/ssr/lib/types.d.ts.map +1 -1
- package/core/src/ssr/render.d.ts +1 -1
- package/core/src/ssr/render.d.ts.map +1 -1
- package/core/src/ssr/stream.d.ts +1 -1
- package/core/src/ssr/stream.d.ts.map +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +2044 -864
- package/elysia/index.js.map +57 -49
- package/elysia/src/index.d.ts +2 -1
- package/elysia/src/index.d.ts.map +1 -1
- package/elysia/src/libs/assets.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +6 -1
- package/elysia/src/libs/cache.d.ts.map +1 -1
- package/elysia/src/libs/caching.d.ts +1 -1
- package/elysia/src/libs/devReload.d.ts +53 -0
- package/elysia/src/libs/devReload.d.ts.map +1 -0
- package/elysia/src/libs/http.d.ts +7 -1
- package/elysia/src/libs/http.d.ts.map +1 -1
- package/elysia/src/libs/i18n.d.ts +15 -4
- package/elysia/src/libs/i18n.d.ts.map +1 -1
- package/elysia/src/libs/image.d.ts +30 -1
- package/elysia/src/libs/image.d.ts.map +1 -1
- package/elysia/src/libs/index.d.ts +2 -2
- package/elysia/src/libs/index.d.ts.map +1 -1
- package/elysia/src/libs/lazyData.d.ts +38 -0
- package/elysia/src/libs/lazyData.d.ts.map +1 -0
- package/elysia/src/libs/llms.d.ts +1 -1
- package/elysia/src/libs/response.d.ts +1 -1
- package/elysia/src/libs/serving.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/plugin.d.ts.map +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/artifacts.d.ts.map +1 -1
- package/elysia/src/routes/content.d.ts +2 -2
- package/elysia/src/routes/content.d.ts.map +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/index.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts +18 -2
- package/elysia/src/routes/internal.d.ts.map +1 -1
- package/elysia/src/routes/liveReloadClient.d.ts +16 -0
- package/elysia/src/routes/liveReloadClient.d.ts.map +1 -0
- package/elysia/src/routes/llms.d.ts +1 -1
- package/elysia/src/routes/llms.d.ts.map +1 -1
- package/elysia/src/routes/og.d.ts +1 -1
- package/elysia/src/routes/redirects.d.ts +1 -1
- package/elysia/src/routes/robots.d.ts +3 -1
- package/elysia/src/routes/robots.d.ts.map +1 -1
- package/elysia/src/routes/rss.d.ts +1 -1
- package/elysia/src/routes/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +3 -1
- package/elysia/src/routes/sitemap.d.ts.map +1 -1
- package/elysia/src/routes/ssr.d.ts +4 -2
- package/elysia/src/routes/ssr.d.ts.map +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/routes/themeCssRefresh.d.ts +17 -0
- package/elysia/src/routes/themeCssRefresh.d.ts.map +1 -0
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +718 -369
- package/react/index.js.map +19 -16
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +5 -1
- package/react/src/components/Image.d.ts.map +1 -1
- package/react/src/components/LazyRoute.d.ts +1 -1
- package/react/src/components/Link.d.ts +18 -5
- package/react/src/components/Link.d.ts.map +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Markdown.d.ts.map +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts.map +1 -1
- package/react/src/hooks/useData.d.ts +11 -1
- package/react/src/hooks/useData.d.ts.map +1 -1
- package/react/src/hooks/useFeed.d.ts +1 -1
- package/react/src/hooks/useLayoutData.d.ts +11 -1
- package/react/src/hooks/useLayoutData.d.ts.map +1 -1
- package/react/src/hooks/useLlms.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearch.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/hooks/useToc.d.ts +1 -1
- package/react/src/i18n/LocaleProvider.d.ts +20 -2
- package/react/src/i18n/LocaleProvider.d.ts.map +1 -1
- package/react/src/i18n/helpers.d.ts +31 -3
- package/react/src/i18n/helpers.d.ts.map +1 -1
- package/react/src/i18n/index.d.ts +2 -2
- package/react/src/i18n/index.d.ts.map +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/lib/bundle.d.ts +27 -0
- package/react/src/lib/bundle.d.ts.map +1 -0
- package/react/src/lib/collection.d.ts +1 -1
- package/react/src/lib/content.d.ts +1 -1
- package/react/src/lib/head.d.ts +37 -1
- package/react/src/lib/head.d.ts.map +1 -1
- package/react/src/lib/index.d.ts +4 -1
- package/react/src/lib/index.d.ts.map +1 -1
- package/react/src/lib/layouts.d.ts +26 -0
- package/react/src/lib/layouts.d.ts.map +1 -0
- package/react/src/lib/lazy-route.d.ts +12 -19
- package/react/src/lib/lazy-route.d.ts.map +1 -1
- package/react/src/lib/route-loader.d.ts +1 -1
- package/react/src/lib/static-data.d.ts +31 -0
- package/react/src/lib/static-data.d.ts.map +1 -0
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +2 -2
- package/react/src/providers/RerouteProvider.d.ts.map +1 -1
- package/react/src/providers/RouterProvider.d.ts +31 -3
- package/react/src/providers/RouterProvider.d.ts.map +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +15 -1
- package/react/src/types/router.d.ts.map +1 -1
- package/telemetry/react.d.ts +1 -1
- package/telemetry/react.js +16 -16
- package/telemetry/react.js.map +2 -2
- package/telemetry/server.d.ts +1 -1
- package/telemetry/server.js +82 -232
- package/telemetry/server.js.map +30 -24
- package/telemetry/src/react/api.d.ts +1 -1
- package/telemetry/src/react/context.d.ts +1 -1
- package/telemetry/src/react/index.d.ts +1 -1
- package/telemetry/src/react/telemetry.d.ts +1 -1
- package/telemetry/src/server/context.d.ts +1 -1
- package/telemetry/src/server/headers/extractor.d.ts +1 -1
- package/telemetry/src/server/headers/index.d.ts +1 -1
- package/telemetry/src/server/headers/presets.d.ts +1 -1
- package/telemetry/src/server/index.d.ts +1 -1
- package/telemetry/src/server/instrumentation.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts +1 -1
- package/telemetry/src/server/sourcemap.d.ts +1 -1
package/README.md
CHANGED
|
@@ -130,6 +130,7 @@ Reroute is a feature-rich file-based routing framework for building fullstack Re
|
|
|
130
130
|
- `<Link>` - Client-side navigation with automatic prefetching (localizes content hrefs)
|
|
131
131
|
- `<Image>` - Optimized images with automatic format negotiation and lazy loading
|
|
132
132
|
- `<Outlet>` - Render nested route components
|
|
133
|
+
- Route groups - `routes/(app)/[layout].tsx` wraps the routes in `(app)/` with one layout, no URL segment
|
|
133
134
|
- `<ContentRoute>` - Dynamic content rendering with metadata injection
|
|
134
135
|
- `<ClientOnly>` - Client-side only rendering with optional layout preservation (className/style props)
|
|
135
136
|
- 🎭 **Providers**:
|
|
@@ -144,6 +145,7 @@ Reroute is a feature-rich file-based routing framework for building fullstack Re
|
|
|
144
145
|
- 🎨 **Format Control** - Support for auto, AVIF, WebP, JPEG, and PNG formats
|
|
145
146
|
- 📐 **Responsive Images** - Automatic srcset generation for multiple device sizes (640-3840px)
|
|
146
147
|
- ⚡ **On-Demand Processing** - Server-side image transformation using Sharp
|
|
148
|
+
- 🧱 **Build-Time Preprocess** - Optional mobile / tablet / desktop bake at `reroute gen --prod`
|
|
147
149
|
- 💾 **Smart Caching** - In-memory and disk cache for optimized images (1-year cache headers)
|
|
148
150
|
- 🔍 **Lazy Loading** - Native lazy loading with IntersectionObserver fallback for older browsers
|
|
149
151
|
- ⏫ **Priority Loading** - Opt-in eager loading for above-the-fold images
|
|
@@ -616,6 +618,8 @@ Files are loaded in order, with later files overriding earlier ones.
|
|
|
616
618
|
- ❌ `DATABASE_URL` - Server-only
|
|
617
619
|
- ❌ `SECRET_KEY` - Server-only
|
|
618
620
|
|
|
621
|
+
A route's or layout's `ssr` (`data`, `head`, `lang`, `sitemap`) is server code too: the browser bundle leaves it out, with every import only `ssr` uses, so a loader can import a database client or call `Bun` freely. Declare it as `export const ssr = …` (or `const ssr = …; export { ssr }`); a form the build can't leave out fails it. When the browser navigates, the server sends the page's head and lang, built as for a full page load (layouts, `meta`, content and `ssr.head`), with its data; the browser swaps the page's own head for it.
|
|
622
|
+
|
|
619
623
|
### TypeScript Support
|
|
620
624
|
|
|
621
625
|
For type safety, create a `env.d.ts` file:
|
|
@@ -670,7 +674,40 @@ src/client/routes/blog/content/
|
|
|
670
674
|
- Flat files under `content/` are the default locale; nest under `content/{locale}/` for translations
|
|
671
675
|
- Collections without locale folders behave as before
|
|
672
676
|
- Default-locale prefix (`/blog/en-US/...`) 302s to the unprefixed URL
|
|
673
|
-
-
|
|
677
|
+
- A locale segment in the URL always wins over cookie / `Accept-Language`
|
|
678
|
+
- `setLocale()` writes `?lang=` and the server 302s to the canonical content URL (and sets the cookie). That is the only way to leave a URL that already has a locale in the path
|
|
679
|
+
- Optional negotiate: `Accept-Language` / cookie can 302 **unprefixed** content URLs to a localized path (`i18n.redirectContentOnNegotiate`, default `true`)
|
|
680
|
+
|
|
681
|
+
### Locale-prefixed pages (`i18n.prefixPages`)
|
|
682
|
+
|
|
683
|
+
Off by default. With `prefixPages: true` every page carries its locale in the URL, so each response depends on its URL alone and a CDN that caches by URL never serves one visitor's language to the next:
|
|
684
|
+
|
|
685
|
+
| URL | Locale |
|
|
686
|
+
|-----|--------|
|
|
687
|
+
| `/compare` | default |
|
|
688
|
+
| `/pt-BR/compare`, `/pt-BR` | pt-BR |
|
|
689
|
+
| `/help/pt-BR/slug` | pt-BR (content keeps its format) |
|
|
690
|
+
|
|
691
|
+
- The cookie and `Accept-Language` never pick a page's locale, and page/data responses send no `Set-Cookie`
|
|
692
|
+
- `/en-US/compare` 301s to `/compare`; a prefix in front of a content URL (`/pt-BR/help/slug`) 301s to `/help/pt-BR/slug`
|
|
693
|
+
- `?lang=xx` 302s to that locale's URL (and only that redirect sets the cookie); `setLocale()` uses it
|
|
694
|
+
- `<Link to="/compare">` renders `/pt-BR/compare` on a pt-BR page; a path that names a locale (`/pt-BR/...`) is left as written, and a link to another locale loads the document
|
|
695
|
+
- `ssr.data` gets the full path as `pathname` (`/pt-BR/compare`), so data is keyed and cached per locale; routes, layouts and params match the unprefixed path
|
|
696
|
+
- Every page gets `hreflang` alternates for each locale plus `x-default`; the sitemap lists each page once per locale
|
|
697
|
+
- `unprefixedPaths: ['/portfolio', '/auth']`: pages that keep one URL for every locale (a PWA scope, a universal link, a payment return). `/portfolio` covers `/portfolio/...`, not `/portfolios`. A prefixed one (`/pt-BR/portfolio`) 301s to its bare URL; otherwise its locale comes from `?lang=`, the cookie or `Accept-Language`, as without `prefixPages`, and it may set the cookie, so don't let a CDN cache it. `Link` leaves them as written, they get no `hreflang`, and the sitemap lists them once. A link from a locale-prefixed page to one loads the document
|
|
698
|
+
- `useRouter().routingPathname` is the path routes match (`/pt-BR/compare` → `/compare`): compare it, not `pathname`, to literals such as `'/'`
|
|
699
|
+
|
|
700
|
+
#### One URL per page, the CDN picks the locale (`localeParam`)
|
|
701
|
+
|
|
702
|
+
For pages shared as one link (a public profile), where `/pt-BR/...` URLs don't fit: a CDN reads the visitor's language and adds it as a query parameter that is part of its cache key, and the page renders in that locale.
|
|
703
|
+
|
|
704
|
+
```ts
|
|
705
|
+
i18n: { localeParam: '__locale' },
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
- The page's locale is that parameter (a content URL's segment still wins), else the default. The cookie, `Accept-Language` and `?lang=` are never read, nothing redirects and no cookie is set, so each response is a function of its URL and the CDN may cache it
|
|
709
|
+
- The CDN adds the parameter to every request, `/__reroute_data` included (reroute reads it from the data request's own query). With Cloudflare, a URL Rewrite Transform Rule: when `starts_with(lower(http.request.headers["accept-language"][0]), "pt")`, set the query to `concat(http.request.uri.query, "&__locale=pt-BR")`
|
|
710
|
+
- Without the CDN (local dev), pages render in the default locale; add `?__locale=pt-BR` to see another
|
|
674
711
|
|
|
675
712
|
### UI Strings
|
|
676
713
|
|
|
@@ -713,6 +750,9 @@ export default defineConfig({
|
|
|
713
750
|
localesDir: 'locales', // catalog directory
|
|
714
751
|
cookie: 'reroute-locale',
|
|
715
752
|
redirectContentOnNegotiate: true, // 302 default content → localized URL
|
|
753
|
+
prefixPages: false, // true: /pt-BR/compare, URL-only locale
|
|
754
|
+
unprefixedPaths: [], // with prefixPages: paths never prefixed
|
|
755
|
+
localeParam: '', // '__locale': a CDN names the locale in the query
|
|
716
756
|
},
|
|
717
757
|
});
|
|
718
758
|
```
|
|
@@ -1165,8 +1205,9 @@ export default defineConfig({
|
|
|
1165
1205
|
Your site now supports:
|
|
1166
1206
|
- `.txt` and `.md` extensions on any route (e.g., `/blog/post.txt`, `/about.md`)
|
|
1167
1207
|
- Accept header content negotiation (`Accept: text/plain`, `Accept: text/markdown`)
|
|
1168
|
-
- `/llms.txt` - Index of all content
|
|
1169
|
-
- `/llms-full.txt` - Complete site content in one file
|
|
1208
|
+
- `/llms.txt` - Index of all content: title, description, and link per page
|
|
1209
|
+
- `/llms-full.txt` - Complete site content in one file (optional; large)
|
|
1210
|
+
- HTML discovery: `Link: rel=alternate` + `<link type="text/markdown">` pointing at the `.md` twin, `Link: rel=llms-txt`, `Vary: Accept`, and `Content-Signal` (also a `Content-Signal:` line in `robots.txt` when robots is enabled)
|
|
1170
1211
|
|
|
1171
1212
|
#### How It Works
|
|
1172
1213
|
|
|
@@ -1199,6 +1240,7 @@ curl -H "Accept: text/html" https://example.com/blog/hello-world # Default
|
|
|
1199
1240
|
- **Flexible exclusions** - Strings, RegExp, or custom functions
|
|
1200
1241
|
- **Works everywhere** - Collections, SSR routes, static pages
|
|
1201
1242
|
- **Auto-discovery** - All content automatically indexed
|
|
1243
|
+
- **Crawler hints** - HTML `Link` / `<link rel="alternate">`, `Content-Signal`, `Vary: Accept`
|
|
1202
1244
|
|
|
1203
1245
|
#### Discovering LLM Files in Your UI
|
|
1204
1246
|
|
package/cli/bin.d.ts
CHANGED