Skip to content

Commit

Permalink
fixed infinite recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 27, 2023
1 parent 1c2bc3b commit 671eaf8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion plugins/multilanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function multilanguage(userOptions?: Partial<Options>): 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)
: "";
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 671eaf8

Please sign in to comment.