1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 07:05:21 -04:00

type errors

This commit is contained in:
Jake Jarvis 2022-05-14 18:24:09 -04:00
parent a97eb0532f
commit 091a41e485
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
4 changed files with 52 additions and 46 deletions

View File

@ -8,10 +8,14 @@ export const ThemeContext: Context<{
* If the user's theme preference is unset, this returns whether the system preference resolved to "light" or "dark".
* If the user's theme preference is set, the preference is returned instead, regardless of their system's theme.
*/
activeTheme?: "light" | "dark";
activeTheme: "light" | "dark" | undefined;
/** Update the theme manually and save to local storage. */
setTheme?: (theme: string) => void;
}> = createContext({});
setTheme: (theme: string) => void;
}> = createContext({
activeTheme: undefined,
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
setTheme: (_) => {},
});
// provider used once in _app.tsx to wrap entire app
export const ThemeProvider = ({

View File

@ -8,7 +8,7 @@ import type { GetServerSidePropsContext, PreviewData } from "next";
import type { ParsedUrlQuery } from "querystring";
export type BuildFeedOptions = {
type?: "rss" | "atom" | "json"; // defaults to rss
type: "rss" | "atom" | "json";
edgeCacheAge?: number; // in seconds, defaults to 43200 (12 hours)
};
@ -16,7 +16,7 @@ export type BuildFeedOptions = {
// all the page needs to do is `return buildFeed(context, { format: "rss" })` from getServerSideProps.
export const buildFeed = async (
context: GetServerSidePropsContext<ParsedUrlQuery, PreviewData>,
options: BuildFeedOptions = {}
options: BuildFeedOptions
): Promise<{ props: Record<string, unknown> }> => {
const { res } = context;
@ -63,7 +63,10 @@ export const buildFeed = async (
res.setHeader("cache-control", `s-maxage=${options.edgeCacheAge ?? 43200}, stale-while-revalidate=3600`);
// generates RSS by default
if (options.type === "atom") {
if (options.type === "rss") {
res.setHeader("content-type", "application/rss+xml; charset=utf-8");
res.write(feed.rss2());
} else if (options.type === "atom") {
res.setHeader("content-type", "application/atom+xml; charset=utf-8");
res.write(feed.atom1());
} else if (options.type === "json") {
@ -72,8 +75,7 @@ export const buildFeed = async (
res.setHeader("content-type", "application/feed+json; charset=utf-8");
res.write(feed.json1());
} else {
res.setHeader("content-type", "application/rss+xml; charset=utf-8");
res.write(feed.rss2());
throw new TypeError("Invalid feed type, must be 'rss', 'atom', or 'json'.");
}
res.end();

View File

@ -21,11 +21,11 @@
"@fontsource/comic-neue": "4.5.8",
"@fontsource/inter": "4.5.10",
"@fontsource/roboto-mono": "4.5.7",
"@giscus/react": "^2.0.3",
"@giscus/react": "^2.0.4",
"@hcaptcha/react-hcaptcha": "^1.3.0",
"@novnc/novnc": "github:novnc/noVNC#7730814b8d43d24db0894b641317be4b9f683da4",
"@octokit/graphql": "^4.8.0",
"@primer/octicons": "^17.1.0",
"@primer/octicons": "^17.2.0",
"@react-spring/web": "^9.4.5",
"@sentry/node": "^6.19.7",
"@sentry/tracing": "^6.19.7",
@ -64,7 +64,7 @@
"react-twitter-embed": "^4.0.4",
"react-use": "^17.3.2",
"reading-time": "^1.5.0",
"rehype-prism-plus": "^1.3.2",
"rehype-prism-plus": "^1.4.0",
"rehype-slug": "^5.0.1",
"remark-gfm": "^3.0.1",
"remark-smartypants": "^2.0.0",
@ -85,7 +85,7 @@
"@types/node": "*",
"@types/prop-types": "^15.7.5",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.3",
"@types/react-dom": "^18.0.4",
"@types/react-is": "^17.0.3",
"@types/remove-markdown": "^0.3.1",
"@types/sanitize-html": "^2.6.2",

View File

@ -1053,10 +1053,10 @@
resolved "https://registry.yarnpkg.com/@fontsource/roboto-mono/-/roboto-mono-4.5.7.tgz#69a89b679ab962ea3591438f35833b09f0f8980f"
integrity sha512-1uBjM95BEz7zJlmmnpNAM5afMvIxx0wqr86eA76vRqZw8OF5wmsRqYfF3caHuVarBH9/AGN7t9h+3UXK8fjq/Q==
"@giscus/react@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@giscus/react/-/react-2.0.3.tgz#d80fb9a5a0c9d5a6364ba6711277ae64d9e4cbe2"
integrity sha512-ynywOgvvlPn7zmWXDWAPr3jqfYC43vwK1g5P8qr528GjyWKXVyxBLJIve/mBrl+aCpZurcaExtsoJ2z6gq+Xgg==
"@giscus/react@^2.0.4":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@giscus/react/-/react-2.0.4.tgz#9b2ae8cdd81ac7701bcc8bd48fad2a9ecb8956b2"
integrity sha512-gaASYFDV2ferpikuT3YqXB13MYD14eGOjY/dmxixqGtIfMAkJbmNr+qQ51E8kefCFcbExjhH0WI54/MmbY1dQQ==
dependencies:
giscus "^1.0.3"
@ -1318,10 +1318,10 @@
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1"
integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==
"@primer/octicons@^17.1.0":
version "17.1.0"
resolved "https://registry.yarnpkg.com/@primer/octicons/-/octicons-17.1.0.tgz#55734bbefa396c44289c94c4427a472380bda078"
integrity sha512-F/YH+WeLDeIVijC8xW3iwyrDEG3asbZSMP40uMI3TXk7HTAaVgziM9/ZXigsCARZjX2nVRvOT4JE0VN2C/5Q5A==
"@primer/octicons@^17.2.0":
version "17.2.0"
resolved "https://registry.yarnpkg.com/@primer/octicons/-/octicons-17.2.0.tgz#6e9be44484100e069006958f28dc75eaba55b1ed"
integrity sha512-A3YetVbJX5J4JGa2AfVrEl1lE3FtT+7HdSzphFRs1QF5OgsUpkNbyjvVxeCxVZaG6zXYbbbPWsPF06PtsIyUWQ==
dependencies:
object-assign "^4.1.1"
@ -1650,9 +1650,9 @@
"@types/unist" "*"
"@types/node@*", "@types/node@^17.0.5":
version "17.0.32"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.32.tgz#51d59d7a90ef2d0ae961791e0900cad2393a0149"
integrity sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw==
version "17.0.33"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.33.tgz#3c1879b276dc63e73030bb91165e62a4509cd506"
integrity sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ==
"@types/parse-json@^4.0.0":
version "4.0.0"
@ -1674,10 +1674,10 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==
"@types/react-dom@^18.0.3":
version "18.0.3"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.3.tgz#a022ea08c75a476fe5e96b675c3e673363853831"
integrity sha512-1RRW9kst+67gveJRYPxGmVy8eVJ05O43hg77G2j5m76/RFJtMbcfAs2viQ2UNsvvDg8F7OfQZx8qQcl6ymygaQ==
"@types/react-dom@^18.0.4":
version "18.0.4"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.4.tgz#dcbcadb277bcf6c411ceff70069424c57797d375"
integrity sha512-FgTtbqPOCI3dzZPZoC2T/sx3L34qxy99ITWn4eoSA95qPyXDMH0ALoAqUp49ITniiJFsXUVBtalh/KffMpg21Q==
dependencies:
"@types/react" "*"
@ -2130,9 +2130,9 @@ camelcase@^6.2.0:
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
caniuse-lite@^1.0.30001332:
version "1.0.30001340"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001340.tgz#029a2f8bfc025d4820fafbfaa6259fd7778340c7"
integrity sha512-jUNz+a9blQTQVu4uFcn17uAD8IDizPzQkIKh3LCJfg9BkyIqExYYdyc/ZSlWUSKb8iYiXxKsxbv4zYSvkqjrxw==
version "1.0.30001341"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001341.tgz#59590c8ffa8b5939cf4161f00827b8873ad72498"
integrity sha512-2SodVrFFtvGENGCv0ChVJIDQ0KPaS1cg7/qtfMaICgeMolDdo/Z2OD32F0Aq9yl6F4YFwGPBS5AaPqNYiW4PoA==
ccount@^1.0.0:
version "1.1.0"
@ -3227,11 +3227,11 @@ get-symbol-description@^1.0.0:
get-intrinsic "^1.1.1"
giscus@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/giscus/-/giscus-1.0.3.tgz#7f6895325c197f9f1a8ff469f09729a2786564ba"
integrity sha512-SaytuVitbLN3f8VaVeClhRvZ8XEIvjy5H4sHfaQne0yb5oKy990F12cNQtgGcTjgC8NZcJdv2bDunqQGY6sr8g==
version "1.0.4"
resolved "https://registry.yarnpkg.com/giscus/-/giscus-1.0.4.tgz#8eabd976d721062d3f73ae5bf80fa92f776598dc"
integrity sha512-ebt3RwDDqcLi/4YuDJnDd8wTrILS+HdNkTmMzfgBNXnl18KWWXXMmY0R3W5n6tVOQU4nzVdxpaQV6Qlflz3KTA==
dependencies:
lit "^2.2.2"
lit "^2.2.3"
github-slugger@^1.1.1:
version "1.4.0"
@ -3265,14 +3265,14 @@ glob@7.1.7:
path-is-absolute "^1.0.0"
glob@^7.1.3, glob@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
version "7.2.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.2.tgz#29deb38e1ef90f132d5958abe9c3ee8e87f3c318"
integrity sha512-NzDgHDiJwKYByLrL5lONmQFpK/2G78SMMfo+E9CuGlX4IkvfKDsiQSNPwAYxEy+e6p7ZQ3uslSLlwlJcqezBmQ==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
minimatch "^3.1.1"
once "^1.3.0"
path-is-absolute "^1.0.0"
@ -3927,7 +3927,7 @@ lit-html@^2.2.0:
dependencies:
"@types/trusted-types" "^2.0.2"
lit@^2.2.2:
lit@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/lit/-/lit-2.2.3.tgz#77203d8f247de7c0d4955817f89e40c927349b9c"
integrity sha512-5/v+r9dH3Pw/o0rhp/qYk3ERvOUclNF31bWb0FiW6MPgwdQIr+/KCt/p3zcd8aPl8lIGnxdGrVcZA+gWS6oFOQ==
@ -4643,7 +4643,7 @@ mimic-fn@^2.1.0:
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
minimatch@^3.0.4, minimatch@^3.1.2:
minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
@ -5247,7 +5247,7 @@ reading-time@^1.5.0:
resolved "https://registry.yarnpkg.com/reading-time/-/reading-time-1.5.0.tgz#d2a7f1b6057cb2e169beaf87113cc3411b5bc5bb"
integrity sha512-onYyVhBNr4CmAxFsKS7bz+uTLRakypIe4R+5A824vBSkQy/hB3fZepoVEf8OVAxzLvK+H/jm9TzpI3ETSm64Kg==
refractor@^4.5.0:
refractor@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/refractor/-/refractor-4.7.0.tgz#aad649d7857acdc0d5792f1a7900867256941ac0"
integrity sha512-X3JUDE7nq1csWs7Etg5v7hW10RzF4lYesEn/KDbllocj0itZrs3paO2ZEgYUXrlgXzY3IN+eDRByyIvzcfF9Tg==
@ -5329,14 +5329,14 @@ rehype-parse@^8.0.2:
parse5 "^6.0.0"
unified "^10.0.0"
rehype-prism-plus@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/rehype-prism-plus/-/rehype-prism-plus-1.3.2.tgz#4ee433200a44b779afa919b48e186f89a9648330"
integrity sha512-fQXzzMpQu+XM/GUsT0GdwfU8gwpUJ1QjE0BLrMjuULkpFW6/GViNvUJKtIiYc9/uSh6k33CB0YbSa90Bs6R3TQ==
rehype-prism-plus@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/rehype-prism-plus/-/rehype-prism-plus-1.4.0.tgz#33ed79908b751de684c5f2c091d80e2aa15f5805"
integrity sha512-btxPe22bzmKBtTfBbcsBLi7CpedGqDneGRYMLJGmv/DSivLfwEkyzEQHpg1LlOmPNlq/0sJgKEuC+qYJv92pdw==
dependencies:
hast-util-to-string "^2.0.0"
parse-numeric-range "^1.3.0"
refractor "^4.5.0"
refractor "^4.7.0"
rehype-parse "^8.0.2"
unist-util-filter "^4.0.0"
unist-util-visit "^4.0.0"