Skip to content

Support array values in findBy filter for multiple authors#1969

Open
reatlat wants to merge 3 commits into
11ty:mainfrom
freshjuice-dev:support-multiple-authors
Open

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

Conversation

@reatlat

@reatlat reatlat commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

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.
Comment thread eleventy.config.js Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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

@Ryuno-Ki Ryuno-Ki left a comment

Copy link
Copy Markdown
Contributor

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)

@reatlat

reatlat commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

Hey @zachleat and @Snapstromegon, just wanted to kindly bump this PR. It's been open for a bit and I'd love to get your eyes on it when you have a moment.

The change is fairly small, it adds array support to the findBy filter so starters/plugins can list multiple authors. It's fully backward-compatible and I've addressed the review feedback from @Ryuno-Ki on locale-safe comparison.

Thanks for all the amazing work on 11ty, really appreciate your time! Let's Build Awesome 🟢

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