diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dbcb0e4..ce683999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project try to adheres to [Semantic Versioning](https://semver.org/), but not always is possible (due the use of unstable features from Deno). Any BREAKING CHANGE between minor versions will be documented here in upper case. +## [Unreleased] +### Fixed +- Infinite recursion of `multilanguage` plugin combined with pagination with the returnPageData option as `true`. + ## [1.19.4] - 2023-11-27 ### Fixed - Tailwind: Fix types for `options`. @@ -2480,6 +2484,7 @@ The first version. [#504]: https://github.com/lumeland/lume/issues/504 [#514]: https://github.com/lumeland/lume/issues/514 +[Unreleased]: https://github.com/lumeland/lume/compare/v1.19.4...HEAD [1.19.4]: https://github.com/lumeland/lume/compare/v1.19.3...v1.19.4 [1.19.3]: https://github.com/lumeland/lume/compare/v1.19.2...v1.19.3 [1.19.2]: https://github.com/lumeland/lume/compare/v1.19.1...v1.19.2 diff --git a/plugins/multilanguage.ts b/plugins/multilanguage.ts index c9f31e85..70c02308 100644 --- a/plugins/multilanguage.ts +++ b/plugins/multilanguage.ts @@ -41,7 +41,7 @@ export default function multilanguage(userOptions?: Partial): Plugin { // Create a new page per language const newPages: Page[] = []; - const id: string = data.id || page.src.path.slice(1); + const id: string | number = data.id ?? page.src.path.slice(1); const basePath: string = typeof page.data.url === "string" ? posix.dirname(page.data.url) : ""; @@ -194,10 +194,18 @@ function filterLanguage( continue; } + if (value instanceof Page) { + continue; + } + + // @ts-ignore: avoid recursive filtering of pages if (isPlainObject(value)) { result[name] = filterLanguage(langs, lang, value); } else if (Array.isArray(value)) { result[name] = value.map((item) => { + if (item instanceof Page) { + return item; + } return isPlainObject(item) ? filterLanguage(langs, lang, item) : item; }); } else {