upgrade deps and fix nullables

This commit is contained in:
eggy
2023-05-23 16:31:52 -04:00
parent 304c9d6f36
commit 5976b6079a
5 changed files with 38 additions and 16 deletions

View File

@@ -14,8 +14,10 @@ function toggleDarkMode() {
}
}
const darkToggle = document.getElementById("dark-toggle");
darkToggle.checked = html.className === "dark";
darkToggle.onclick = toggleDarkMode;
if (darkToggle) {
darkToggle.checked = html.className === "dark";
darkToggle.onclick = toggleDarkMode;
}
// github commit fetcher
// pulled from CommitStatBox.vue
const FEED_URL = "https://api.github.com/users/potatoeggy/events";
@@ -24,6 +26,10 @@ const latestEvent = results.find((e) => e.type === "PushEvent");
const latestCommit = latestEvent.payload.commits[0];
const commitImg = document.getElementById("github-commit-img");
const commitAnchor = document.getElementById("github-commit-a");
commitImg.src = `https://opengraph.githubassets.com/hash/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
commitAnchor.href = `https://github.com/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
if (commitImg) {
commitImg.src = `https://opengraph.githubassets.com/hash/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
}
if (commitAnchor) {
commitAnchor.href = `https://github.com/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
}
export {};

View File

@@ -20,9 +20,14 @@ function toggleDarkMode() {
}
}
const darkToggle = document.getElementById("dark-toggle") as HTMLInputElement;
darkToggle.checked = html.className === "dark";
darkToggle.onclick = toggleDarkMode;
const darkToggle = document.getElementById(
"dark-toggle"
) as HTMLInputElement | null;
if (darkToggle) {
darkToggle.checked = html.className === "dark";
darkToggle.onclick = toggleDarkMode;
}
// github commit fetcher
// pulled from CommitStatBox.vue
@@ -35,13 +40,18 @@ const latestCommit = latestEvent.payload.commits[0];
const commitImg = document.getElementById(
"github-commit-img"
) as HTMLImageElement;
) as HTMLImageElement | null;
const commitAnchor = document.getElementById(
"github-commit-a"
) as HTMLAnchorElement;
commitImg.src = `https://opengraph.githubassets.com/hash/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
commitAnchor.href = `https://github.com/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
if (commitImg) {
commitImg.src = `https://opengraph.githubassets.com/hash/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
}
if (commitAnchor) {
commitAnchor.href = `https://github.com/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
}
// to make this an esm module for top-level await
export {};