Skip to content

Commit a0e0872

Browse files
committed
🚑 adapt the parser to the new github page markup
1 parent 29c7ee4 commit a0e0872

File tree

1 file changed

+13
-9
lines changed
  • packages/github-user-contribution

1 file changed

+13
-9
lines changed

‎packages/github-user-contribution/index.ts‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,22 @@ const parseUserPage = (content: string) => {
4747
let x = 0;
4848
let lastYAttribute = 0;
4949

50-
const rects = Array.from(block.matchAll(/<rect[^>]*>/g)).map(([m]) => {
51-
const date = m.match(/data-date="([^"]+)"/)![1];
52-
const count = +m.match(/data-count="([^"]+)"/)![1];
53-
const level = +m.match(/data-level="([^"]+)"/)![1];
54-
const yAttribute = +m.match(/y="([^"]+)"/)![1];
50+
const rects = Array.from(block.matchAll(/<rect[^>]*>[^<]*<\/rect>/g)).map(
51+
([m]) => {
52+
const date = m.match(/data-date="([^"]+)"/)![1];
53+
const level = +m.match(/data-level="([^"]+)"/)![1];
54+
const yAttribute = +m.match(/y="([^"]+)"/)![1];
5555

56-
if (lastYAttribute > yAttribute) x++;
56+
const literalCount = m.match(/(No|\d+) contributions? on/)![1];
57+
const count = literalCount === "No" ? 0 : +literalCount;
5758

58-
lastYAttribute = yAttribute;
59+
if (lastYAttribute > yAttribute) x++;
5960

60-
return { date, count, level, x, yAttribute };
61-
});
61+
lastYAttribute = yAttribute;
62+
63+
return { date, count, level, x, yAttribute };
64+
}
65+
);
6266

6367
const yAttributes = Array.from(
6468
new Set(rects.map((c) => c.yAttribute)).keys()

0 commit comments

Comments
 (0)