next-multilingual
Advanced tools
Comparing version 0.2.0 to 0.3.0
import type { Rewrite } from 'next/dist/lib/load-custom-routes'; | ||
/** Object representing a simplified version of the route manifest files. */ | ||
export declare type RoutesManifest = { | ||
rewrites: Rewrite[]; | ||
}; | ||
/** | ||
@@ -3,0 +7,0 @@ * Get the Next.js `Rewrite` objects directly from the build manifest. |
@@ -18,3 +18,18 @@ "use strict"; | ||
return rewritesCache; | ||
// Get the content from the Next.js build-manifest (.next/build-manifest.json). | ||
// Try to get the content of the routes-manifest (.next/routes-manifest.json) first - this is only available on builds. | ||
const routesManifestPath = (0, path_1.resolve)('.next', 'routes-manifest.json'); | ||
if ((0, fs_1.existsSync)(routesManifestPath)) { | ||
const routesManifest = JSON.parse((0, fs_1.readFileSync)(routesManifestPath, 'utf8')); | ||
const rewrites = routesManifest.rewrites.map((rewrite) => { | ||
return { | ||
source: rewrite.source, | ||
destination: rewrite.destination, | ||
locale: rewrite.locale, | ||
}; | ||
}); | ||
// Save to the cache. | ||
rewritesCache = rewrites; | ||
return rewritesCache; | ||
} | ||
// If the server routes-manifest is not available, then get can get the rewrites from the client build manifest. | ||
const buildManifestPath = (0, path_1.resolve)('.next', 'build-manifest.json'); | ||
@@ -21,0 +36,0 @@ const buildManifestContent = (0, fs_1.readFileSync)(buildManifestPath, 'utf8'); |
{ | ||
"name": "next-multilingual", | ||
"description": "An opinionated end-to-end multilingual solution for Next.js.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -5,2 +5,7 @@ # ![next-multilingual](./assets/next-multilingual-banner.svg) | ||
Check out our [demo app](https://next-multilingual-example.avansai.com)! | ||
[![Try me](https://img.shields.io/badge/-Try%20me!-green?style=for-the-badge)](https://next-multilingual-example.avansai.com) | ||
## Installation 💻 | ||
@@ -7,0 +12,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130785
2088
611