Added details prop to summary actors.
This commit is contained in:
parent
14bca958fd
commit
f4acee53c4
|
|
@ -16,12 +16,14 @@ export default {
|
|||
gender: 'female',
|
||||
ageThen: 26,
|
||||
ageFromBirth: 31,
|
||||
dateOfBirth: new Date(1999, 2, 2),
|
||||
},
|
||||
{
|
||||
name: 'Mo The Fucker',
|
||||
gender: 'male',
|
||||
ageThen: 32,
|
||||
ageFromBirth: 37,
|
||||
dateOfBirth: new Date(1988, 5, 12),
|
||||
},
|
||||
],
|
||||
tags: [
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue