1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-25 00:21:28 +02:00

Add roadmap-renderer package

This commit is contained in:
Kamran Ahmed
2022-08-28 03:11:00 +04:00
parent 83933b9df6
commit 80f9873331
6 changed files with 36 additions and 4 deletions

21
lib/renderer.ts Normal file
View File

@@ -0,0 +1,21 @@
export function removeSortingInfo(groupId: string) {
return (groupId || '').replace(/^\d+-/, '');
}
export function queryGroupElementsById(groupId: string) {
const elements = document.querySelectorAll(
`[data-group-id$="-${groupId}"]`
) as any;
const matchingElements: HTMLElement[] = [];
elements.forEach((element: HTMLElement) => {
const foundGroupId = element?.dataset?.groupId || '';
const validGroupRegex = new RegExp(`^\\d+-${groupId}$`);
if (validGroupRegex.test(foundGroupId)) {
matchingElements.push(element);
}
});
return matchingElements;
}