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 | 8770424ae7a0affbb4b05903d355fe856f853797 (patch) | |
| tree | 7515a66d6003d6eeed225677d606ca4e6847d791 /src/scraper.ts | |
| parent | 9c0a011974f1392110164052c3481509641d2f58 (diff) | |
Image support
Diffstat (limited to 'src/scraper.ts')
| -rw-r--r-- | src/scraper.ts | 18 |
1 files changed, 13 insertions, 5 deletions
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, |
