-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move displayCreators helper into a global helper file as it's used gl…
…obally
- Loading branch information
Showing
4 changed files
with
24 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
ManifestationDetailsFragment, | ||
WorkFullWorkPageFragment, | ||
} from "@/lib/graphql/generated/fbi/graphql" | ||
|
||
export const displayCreators = ( | ||
creators: WorkFullWorkPageFragment["creators"] | ManifestationDetailsFragment["contributors"], | ||
amount: number | ||
) => { | ||
return creators.reduce((acc, creator, index) => { | ||
// We shorten to max <amount> creators | ||
if (index === amount) { | ||
return acc + ", et. al" | ||
} | ||
// We don't want to show one person twice | ||
if (index > amount || acc.includes(creator.display)) { | ||
return acc | ||
} | ||
return acc + (index > 0 ? ", " : "") + creator.display | ||
}, "") | ||
} |