aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scraper.test.ts4
-rw-r--r--src/scraper.ts9
-rw-r--r--views/_tree.eta12
3 files changed, 15 insertions, 10 deletions
diff --git a/src/scraper.test.ts b/src/scraper.test.ts
index d6991d7..f9b60e8 100644
--- a/src/scraper.test.ts
+++ b/src/scraper.test.ts
@@ -36,7 +36,7 @@ describe("GitHub scraper", () => {
assert.ok(data.info.latestReleaseDate?.startsWith("2026-03-25"));
assert.ok(data.items.length > 0);
- assert.ok(Object.keys(data.overviewHtml ?? {}).includes("README.md"));
+ assert.ok(typeof data.overviewHtml?.["README.md"] === "string");
});
it("should fetch tree", async () => {
@@ -60,7 +60,7 @@ describe("GitHub scraper", () => {
},
]);
- assert.ok(Object.keys(data.overviewHtml ?? {}).includes("README.md"));
+ assert.ok(typeof data.overviewHtml?.["README.md"] === "string");
});
it("should fetch text blob", async () => {
diff --git a/src/scraper.ts b/src/scraper.ts
index 760a306..53f2bb1 100644
--- a/src/scraper.ts
+++ b/src/scraper.ts
@@ -31,7 +31,8 @@ interface TreeItem {
interface OverviewFile {
displayName: string;
- richText?: string;
+ // null when GitHub includes the file without rendered content.
+ richText?: string | null;
}
interface IssueNode {
@@ -220,7 +221,7 @@ interface GitHubNav extends GitHubCommon {
export interface GitHubTree extends GitHubNav {
items: TreeItem[];
- overviewHtml?: Record<string, string>;
+ overviewHtml?: Record<string, string | null>;
}
export interface RepoInfo {
@@ -443,8 +444,8 @@ function parseRepoInfo(html: string): RepoInfo {
function extractOverviewHtml(
overviewFiles: OverviewFile[] = [],
-): Record<string, string> | undefined {
- const result: Record<string, string> = {};
+): Record<string, string | null> | undefined {
+ const result: Record<string, string | null> = {};
for (const file of overviewFiles) {
if (file.richText !== undefined) {
result[file.displayName] = file.richText;
diff --git a/views/_tree.eta b/views/_tree.eta
index 311762f..ed6eee9 100644
--- a/views/_tree.eta
+++ b/views/_tree.eta
@@ -18,9 +18,13 @@
<% if (it.overviewHtml) { %>
<% for (const [filename, html] of Object.entries(it.overviewHtml)) { %>
- <div class="overview box">
- <header><%= filename %></header>
- <%~ html %>
- </div>
+ <% if (html !== null) { %>
+ <div class="overview box">
+ <header><%= filename %></header>
+ <%~ html %>
+ </div>
+ <% } else { %>
+ <!-- No rendered content for <%= filename %> -->
+ <% } %>
<% } %>
<% } %>