diff --git a/README.md b/README.md index 9d63cd0..f2a9711 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ After hand-written HTML and a static site generator comes Nuxt! Post-build instructions (while prerendering is bork) - - Compile `/script.ts` to `/script.js` (`tsc script.ts -m esnext -t esnext --moduleReslution node`) +- Compile `/script.ts` to `/script.js` (`tsc script.ts -m esnext -t esnext --moduleResolution node`) Look at the [nuxt 3 documentation](https://v3.nuxtjs.org) to learn more. diff --git a/package.json b/package.json index d69834d..91bf9e9 100644 --- a/package.json +++ b/package.json @@ -12,13 +12,14 @@ "@nuxtjs/color-mode": "^3.2.0", "@nuxtjs/tailwindcss": "^6.2.0", "@tailwindcss/typography": "^0.5.2", + "@types/node": "^20.2.3", "nuxt": "3.3.3", "reading-time": "^2.0.0-1", "rehype-katex": "^6.0.2", "remark-math": "^5.1.1", "sass": "^1.57.1", "sitemap": "^7.1.1", - "typescript": "^4.7.4", + "typescript": "^5.0.4", "unist-util-visit": "^4.1.0", "vite-svg-loader": "^4.0.0" }, diff --git a/public/script.js b/public/script.js index 7bce2a1..5d02c8b 100644 --- a/public/script.js +++ b/public/script.js @@ -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 {}; diff --git a/public/script.ts b/public/script.ts index 100100c..a582e17 100644 --- a/public/script.ts +++ b/public/script.ts @@ -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 {}; diff --git a/yarn.lock b/yarn.lock index 7177564..8838931 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1000,6 +1000,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.45.tgz#2c0fafd78705e7a18b7906b5201a522719dc5190" integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw== +"@types/node@^20.2.3": + version "20.2.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.2.3.tgz#b31eb300610c3835ac008d690de6f87e28f9b878" + integrity sha512-pg9d0yC4rVNWQzX8U7xb4olIOFuuVL9za3bzMT2pu2SU0SNEi66i2qrvhE2qt0HvkhuCaWJu7pLNOt/Pj8BIrw== + "@types/parse-json@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" @@ -5967,10 +5972,10 @@ type-is@^1.6.16: media-typer "0.3.0" mime-types "~2.1.24" -typescript@^4.7.4: - version "4.9.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +typescript@^5.0.4: + version "5.0.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" + integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== ufo@^1.0.0, ufo@^1.1.0, ufo@^1.1.1: version "1.1.1"