Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions 11ty/techniques.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,28 @@ export async function getTechniqueAssociations(
}

// Remove duplicates (due to similar shape across understanding docs) and sort by SC number
for (const [key, list] of Object.entries(associations))
associations[key] = uniqBy(list, (v) => JSON.stringify(v)).sort((a, b) =>
for (const [key, list] of Object.entries(associations)) {
const deduplicatedList = uniqBy(list, (v) => JSON.stringify(v)).sort((a, b) =>
wcagSort(a.criterion, b.criterion)
);
// Remove entries that are redundant of a more generalized preceding entry
for (let i = 1; i < deduplicatedList.length; i++) {
const previousEntry = deduplicatedList[i - 1];
const entry = deduplicatedList[i];
if (
entry.criterion.id === previousEntry.criterion.id &&
entry.type === previousEntry.type &&
!previousEntry.hasUsageChildren &&
!previousEntry.usageParentDescription &&
!previousEntry.usageParentIds.length &&
!previousEntry.with.length
) {
deduplicatedList.splice(i, 1);
i--; // Next item is now in this index; repeat processing it
}
}
associations[key] = deduplicatedList;
}

return associations;
}
Expand Down