Added details prop to summary actors.
This commit is contained in:
@@ -27,14 +27,65 @@ const propProcessors = {
|
||||
return sceneInfo.actors
|
||||
.filter((actor) => genders.includes(actor.gender))
|
||||
.map((actor) => {
|
||||
const curatedActor = {
|
||||
...actor,
|
||||
age: actor.ageThen,
|
||||
ageNow: actor.age,
|
||||
g: actor.gender?.charAt(0),
|
||||
G: actor.gender?.charAt(0).toUpperCase(),
|
||||
dateOfBirth: actor.dateOfBirth && format(actor.dateOfBirth, 'yyyy-MM-dd'),
|
||||
};
|
||||
|
||||
if (options.format) {
|
||||
return formatTemplate(options.format, Object.fromEntries(Object.entries({
|
||||
...actor,
|
||||
age: actor.ageThen,
|
||||
ageNow: actor.age,
|
||||
g: actor.gender?.charAt(0),
|
||||
G: actor.gender?.charAt(0).toUpperCase(),
|
||||
}).map(([key, value]) => [key, value ?? '']))); // don't render `null`
|
||||
return formatTemplate(options.format, Object.fromEntries(Object.entries(curatedActor).map(([key, value]) => [key, value ?? '']))); // don't render `null`
|
||||
}
|
||||
|
||||
if (options.details) {
|
||||
return options.details
|
||||
.map((parentDetail) => {
|
||||
if (parentDetail.details) { // already nested
|
||||
return {
|
||||
...parentDetail,
|
||||
details: parentDetail.details.map((detail) => {
|
||||
if (detail.key) {
|
||||
return detail;
|
||||
}
|
||||
|
||||
return { key: detail };
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
if (parentDetail.key) {
|
||||
return {
|
||||
details: [parentDetail],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
details: [{ key: parentDetail }],
|
||||
};
|
||||
})
|
||||
.map((parentDetail) => {
|
||||
const curatedDetails = parentDetail.details
|
||||
.filter((detail) => !!curatedActor[detail.key])
|
||||
.map((detail) => {
|
||||
if (detail.wrap) {
|
||||
return `${detail.wrap[0]}${curatedActor[detail.key]}${detail.wrap[1]}`;
|
||||
}
|
||||
|
||||
return curatedActor[detail.key];
|
||||
})
|
||||
.join(parentDetail.delimiter ?? ' ');
|
||||
|
||||
if (parentDetail.wrap) {
|
||||
return `${parentDetail.wrap[0]}${curatedDetails}${parentDetail.wrap[1]}`;
|
||||
}
|
||||
|
||||
return curatedDetails;
|
||||
})
|
||||
.filter((parentDetail) => !!parentDetail)
|
||||
.join(options.detailDelimiter ?? ' ');
|
||||
}
|
||||
|
||||
return actor.name;
|
||||
|
||||
Reference in New Issue
Block a user