1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-01-10 16:22:55 -05:00

less resource-intensive methods of parsing URLs

This commit is contained in:
2022-06-01 18:40:57 -04:00
parent d1ee8b2632
commit 33c210aacf
16 changed files with 195 additions and 188 deletions

View File

@@ -15,7 +15,7 @@ export type CaptchaProps = {
onClose?: () => any;
onChalExpired?: () => any;
onError?: (event: string) => any;
onVerify?: (token: string) => any;
onVerify?: (token: string, ekey: string) => any;
onLoad?: () => any;
/* eslint-enable @typescript-eslint/no-explicit-any */
};
@@ -32,7 +32,7 @@ const Captcha = ({ size = "normal", theme, className, ...rest }: CaptchaProps) =
reCaptchaCompat={false}
tabIndex={0}
size={size}
theme={theme || (activeTheme === "dark" ? "dark" : "light")}
theme={theme || (activeTheme === "dark" ? activeTheme : "light")}
{...rest}
/>
)}

View File

@@ -29,7 +29,7 @@ const Comments = ({ title, ...rest }: CommentsProps) => {
mapping="specific"
reactionsEnabled="1"
emitMetadata="0"
theme={activeTheme === "dark" ? "dark" : "light"}
theme={activeTheme === "dark" ? activeTheme : "light"}
/>
</Wrapper>
);

View File

@@ -19,7 +19,7 @@ export type HeadingAnchorProps = ComponentProps<typeof AnchorLink> & {
const HeadingAnchor = ({ id, title, ...rest }: HeadingAnchorProps) => {
return (
<AnchorLink href={`#${id}`} title={`Jump to "${title}"`} tabIndex={-1} aria-hidden={true} {...rest}>
<AnchorLink href={`#${id}`} title={`Jump to "${title}"`} aria-hidden={true} {...rest}>
<Icon />
</AnchorLink>
);

View File

@@ -69,15 +69,16 @@ export type LayoutProps = ComponentProps<typeof Flex> & {
const Layout = ({ container = true, children, ...rest }: LayoutProps) => {
const { activeTheme } = useTheme();
const skipNavId = "skip-nav";
return (
<>
<Head>
{/* dynamically set browser theme color to match the background color; default to light for SSR */}
<meta name="theme-color" content={themeColors[activeTheme === "dark" ? "dark" : "light"]} />
<meta name="theme-color" content={themeColors[activeTheme === "dark" ? activeTheme : "light"]} />
</Head>
<SkipNavLink href="#skip-nav" role="link" tabIndex={0}>
<SkipNavLink href={`#${skipNavId}`} role="link" tabIndex={0}>
Skip to content
</SkipNavLink>
@@ -88,7 +89,7 @@ const Layout = ({ container = true, children, ...rest }: LayoutProps) => {
{container ? (
<Default>
<Container>
<div id="skip-nav" />
<div id={skipNavId} />
{children}
</Container>
</Default>

View File

@@ -46,14 +46,14 @@ export type LinkProps = Omit<ComponentProps<typeof StyledLink>, "href"> &
const Link = ({ href, rel, target, prefetch = false, underline = true, openInNewTab, ...rest }: LinkProps) => {
// This component auto-detects whether or not this link should open in the same window (the default for internal
// links) or a new tab (the default for external links). Defaults can be overridden with `openInNewTab={true}`.
const isExternal = typeof href === "string" ? new URL(href as string, baseUrl).origin !== baseUrl : false;
const isExternal = typeof href === "string" && !href.startsWith("/") && !href.startsWith(baseUrl);
if (openInNewTab || isExternal) {
return (
<StyledLink
href={href}
target={target || "_blank"}
rel={[rel, "noopener", isExternal ? "noreferrer" : ""].join(" ").trim()}
rel={`${rel || ""} noopener ${isExternal ? "noreferrer" : ""}`.trim()}
underline={underline}
{...rest}
/>

View File

@@ -30,7 +30,7 @@ const ThemeToggle = ({ className }: ThemeToggleProps) => {
const maskId = useId(); // SSR-safe ID to cross-reference areas of the SVG
// default to light since `activeTheme` might be undefined
const safeTheme = activeTheme === "dark" ? "dark" : "light";
const safeTheme = activeTheme === "dark" ? activeTheme : "light";
// accessibility: skip animation if user prefers reduced motion
useEffect(() => {

View File

@@ -16,7 +16,7 @@ const TweetEmbed = ({ id, options }: TweetEmbedProps) => {
options={{
dnt: true,
align: "center",
theme: activeTheme === "dark" ? "dark" : "light",
theme: activeTheme === "dark" ? activeTheme : "light",
...options,
}}
/>

View File

@@ -60,7 +60,7 @@ const VNC = ({ server }: VNCProps) => {
// ends the session forcefully
const disconnectVM = () => {
try {
rfbRef.current.disconnect();
rfbRef.current?.disconnect();
setConnected(false);
} catch (error) {} // eslint-disable-line no-empty
};