Skip to content

Support array values in findBy filter for multiple authors#1969

Open
reatlat wants to merge 3 commits into11ty:mainfrom
freshjuice-dev:support-multiple-authors
Open

Support array values in findBy filter for multiple authors#1969
reatlat wants to merge 3 commits into11ty:mainfrom
freshjuice-dev:support-multiple-authors

Conversation

@reatlat
Copy link
Contributor

@reatlat reatlat commented Feb 8, 2026

Summary

  • Enhance the findBy filter in eleventy.config.js to support array values, enabling fields like author to list multiple authors
  • Update FreshJuice starters to use ["freshjuice-dev", "reatlat"] as a real-world use case

Problem

Currently, starters (and plugins) can only have a single author string. This means a project with multiple contributors can only appear on one author's page.

Solution

Add an Array.isArray() check to the findBy function so that when a field value is an array, it matches if any element in the array equals the search value. This is fully backward-compatible — existing string values continue to work unchanged.

// Before (string only)
"author": "freshjuice-dev"

// After (string or array)
"author": ["freshjuice-dev", "reatlat"]

Test plan

  • Verified locally that array-based authors render correctly on both author pages
  • Confirmed existing single-string authors are unaffected
  • Case-insensitive matching works for array elements

Allow the findBy filter to match against array fields, enabling
support for multiple authors on starters, plugins, etc.
e.g. "author": ["user-a", "user-b"]
Demonstrates the new array support in the findBy filter by listing
multiple authors on FreshJuice starter projects.

if (Array.isArray(gotten)) {
if (typeof value === "string") {
let valueLower = value.toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might lead to some issues down the line (Turkish-I problem).

I recommend using localeCompare instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thanks! Switched to localeCompare with { sensitivity: "base" } in both the array and string comparison paths.

Avoids the Turkish-I problem and other locale-specific casing issues.
@reatlat reatlat requested a review from Ryuno-Ki March 7, 2026 15:43
Copy link
Contributor

@Ryuno-Ki Ryuno-Ki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (But I don't have permissions to actually get this PR in)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants