Added format option to actors, exposing age and gender.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { format } from 'date-fns';
|
||||
import { parse } from 'yaml';
|
||||
import formatTemplate from 'template-format';
|
||||
|
||||
import slugify from '#/utils/slugify.js';
|
||||
import ellipsis from '#/utils/ellipsis.js';
|
||||
@@ -13,6 +14,10 @@ const genderMap = {
|
||||
};
|
||||
|
||||
const propProcessors = {
|
||||
...Object.fromEntries(Object.entries({
|
||||
// aliases
|
||||
shoot: 'shootId',
|
||||
}).map(([key, alias]) => [key, (sceneInfo) => sceneInfo[alias]])),
|
||||
link: (sceneInfo, _options, env) => `${env.origin}/scene/${sceneInfo.id}/${sceneInfo.slug}`,
|
||||
channel: (sceneInfo) => sceneInfo.channel?.name || sceneInfo.network?.name,
|
||||
network: (sceneInfo) => sceneInfo.network?.name || sceneInfo.channel?.name,
|
||||
@@ -21,7 +26,19 @@ const propProcessors = {
|
||||
|
||||
return sceneInfo.actors
|
||||
.filter((actor) => genders.includes(actor.gender))
|
||||
.map((actor) => actor.name);
|
||||
.map((actor) => {
|
||||
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 actor.name;
|
||||
});
|
||||
},
|
||||
tags: (sceneInfo, options) => sceneInfo.tags
|
||||
?.filter((tag) => {
|
||||
|
||||
Reference in New Issue
Block a user