Skip to content

Commit

Permalink
Merge pull request #1444 from danskernesdigitalebibliotek/develop
Browse files Browse the repository at this point in the history
Release 2024.38.1
  • Loading branch information
kasperg authored Sep 20, 2024
2 parents 65e8999 + 29cce46 commit a36a48a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/core/utils/helpers/general.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef } from "react";
import dayjs from "dayjs";
import { uniq } from "lodash";
import { first, uniq } from "lodash";
import { vi } from "vitest";
import { CoverProps } from "../../../components/cover/cover";
import { UseTextFunction } from "../text";
Expand Down Expand Up @@ -67,13 +67,18 @@ const getCreatorsFromManifestations = (manifestations: Manifestation[]) => {
return Array.from(new Set(creators)) as string[];
};

export const creatorsToString = (creators: string[], t: UseTextFunction) => {
export const creatorsToString = (
creators: string[],
t: UseTextFunction
): string => {
if (creators.length > 1) {
const firstTwo = creators.slice(0, 2);
return `${firstTwo.join(", ")} ${t("etAlText")}`;
}

return creators[0];
if (creators.length === 1) {
return first(creators) as string;
}
return "";
};

export const getCreatorTextFromManifestations = (
Expand Down

0 comments on commit a36a48a

Please sign in to comment.