From 8770424ae7a0affbb4b05903d355fe856f853797 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Wed, 28 Jan 2026 15:10:00 -0500 Subject: Image support --- src/scraper.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/scraper.ts') diff --git a/src/scraper.ts b/src/scraper.ts index 05afc33..e58402a 100644 --- a/src/scraper.ts +++ b/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, -- cgit v1.3.1