MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / getAuthorWithId

Function getAuthorWithId

apps/site/util/author.ts:20–47  ·  view source on GitHub ↗
(usernames: Array<string>, hasUrl: boolean)

Source from the content-addressed store, hash-verified

18};
19
20export const getAuthorWithId = (usernames: Array<string>, hasUrl: boolean) => {
21 const mapIdToAuthor = (username: string) => {
22 const author = Object.values(authors).find(
23 ({ id }) => id.toLowerCase() === username.toLowerCase()
24 );
25
26 if (author) {
27 const { id, name, website } = author;
28
29 return {
30 image: getGitHubAvatarUrl(id),
31 name,
32 nickname: id,
33 fallback: getAcronymFromString(name),
34 url: hasUrl ? website : undefined,
35 };
36 }
37
38 return {
39 image: getGitHubAvatarUrl(username),
40 nickname: username,
41 fallback: getAcronymFromString(username),
42 url: hasUrl ? `https://github.com/${username}` : undefined,
43 };
44 };
45
46 return usernames.map(mapIdToAuthor);
47};
48
49export const getAuthorWithName = (names: Array<string>, hasUrl: boolean) => {
50 const mapNameToAuthor = (username: string) => {

Callers 2

author.test.mjsFile · 0.90
getAuthorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected