// labels per scene relation type, keyed by which side of the relation the related scene is on // relations point from the derivation or compilation (source) to the original or compilation part (target) // symmetric types like variants have no direction, and are keyed 'both' // listed in the order they're offered, most common first const relationLabels = { rerelease: { target: 'Rerelease of', source: 'Rereleased as' }, bts: { target: 'Behind the scenes of', source: 'Has behind the scenes' }, variant: { both: 'Variant of' }, compilation: { target: 'Compilation features', source: 'Featured in compilation' }, remaster: { target: 'Remaster of', source: 'Remastered as' }, reedit: { target: 'Re-edit of', source: 'Re-edited as' }, }; const relationOrder = Object.keys(relationLabels); // types without a label go last, alphabetically export function sortRelationTypes(types, getType = (type) => type) { return types.toSorted((typeA, typeB) => { const indexA = relationOrder.indexOf(getType(typeA)); const indexB = relationOrder.indexOf(getType(typeB)); return (indexA === -1 ? Infinity : indexA) - (indexB === -1 ? Infinity : indexB) || getType(typeA).localeCompare(getType(typeB)); }); } export function getRelationLabel(type, direction) { if (relationLabels[type]?.[direction]) { return relationLabels[type][direction]; } // fallback for types added later without a label return direction === 'source' ? `Has ${type}` : `${type.charAt(0).toUpperCase()}${type.slice(1)} of`; } export default relationLabels;