diff options
| author | Joe Mou <dev@mou.fo> | 2026-01-28 15:10:00 -0500 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-01-28 15:32:53 -0500 |
| commit | 631bc70d94cd12d0432cca1a220a3642eea6976a (patch) | |
| tree | 184c444585702ef8d8e58e95cf7946b778f71426 /cgithub/src/scraper.ts | |
| parent | 71442a856d2180c68a51a1db480514d611137bd0 (diff) | |
Image support
Diffstat (limited to 'cgithub/src/scraper.ts')
| -rw-r--r-- | cgithub/src/scraper.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/cgithub/src/scraper.ts b/cgithub/src/scraper.ts index 05afc33..e58402a 100644 --- a/cgithub/src/scraper.ts +++ b/cgithub/src/scraper.ts @@ -68,11 +68,12 @@ interface RawPayload { headerInfo: { blobSize: string; lineInfo: { - truncatedLoc: string; - truncatedSloc: string; + truncatedLoc: string | null; + truncatedSloc: string | null; }; }; - language?: string; + language: string | null; + image: boolean; rawLines: string[] | null; colorizedLines: string[] | null; richText: string | null; @@ -139,6 +140,7 @@ export interface GitHubRepo extends GitHubTree { export interface GitHubBlob extends GitHubNav { language: string | null; size: string; + image: boolean; textLines: string[] | null; htmlLines: string[] | null; htmlContent: string | null; @@ -302,12 +304,18 @@ export async function getGitHubBlob( htmlLines = blob.rawLines.map((line, i) => applyStyling(line, stylingDirectives[i])); } - // TODO fine tune - const size = `${headerInfo.blobSize} / ${headerInfo.lineInfo.truncatedLoc} lines / ${headerInfo.lineInfo.truncatedSloc} loc`; + let size = headerInfo.blobSize; + if (headerInfo.lineInfo.truncatedLoc) { + size += ` / ${headerInfo.lineInfo.truncatedLoc} lines`; + } + if (headerInfo.lineInfo.truncatedSloc) { + size += ` / ${headerInfo.lineInfo.truncatedSloc} loc`; + } return extractGitHub(payload, { language: blob.language || null, size, + image: blob.image, textLines: blob.rawLines, htmlLines, htmlContent: blob.richText, |
