Skip to content

Commit

Permalink
SEO and perf optimizations (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrvecera authored Jun 26, 2023
1 parent 1e5ec43 commit 69731dc
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const Header: React.FC<HeaderProps> = () => {
<Anchor component={Link} href={"/"} className={cx(classes.link)}>
<Group spacing="xs">
<Image
src="/logo/android-icon-36x36.png"
src="/logo/android-icon-48x48.png"
width={30}
height={30}
alt={"COH3 Stats logo"}
Expand Down
1 change: 1 addition & 0 deletions components/icon-button/icon-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const IconButton: React.FC<IconButtonProps> = ({
radius="md"
className={className}
sx={sx}
aria-label={label?.toString()}
>
{children}
</ActionIcon>
Expand Down
7 changes: 6 additions & 1 deletion components/icon/discord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ const useStyles = createStyles(() => ({
export const Discord: React.FC = () => {
const { classes } = useStyles();
return (
<a href={config.DISCORD_INVITE_LINK} target="_blank" rel="noopener noreferrer">
<a
href={config.DISCORD_INVITE_LINK}
target="_blank"
rel="noopener noreferrer nofollow"
title={"Link to our discord channel"}
>
<IconButton label="Discord channel" className={classes.root}>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down
7 changes: 6 additions & 1 deletion components/icon/donate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { IconButton } from "../icon-button/icon-button";
import config from "../../config";

export const Donate: React.FC = () => (
<a href={config.DONATION_LINK} target="_blank" rel="noopener noreferrer">
<a
href={config.DONATION_LINK}
target="_blank"
rel="noopener noreferrer"
title={"Link to our donation pages."}
>
<IconButton label="Donate">
<Image
src="/kofi_s_logo_nolabel.webp"
Expand Down
7 changes: 6 additions & 1 deletion components/icon/github.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { IconButton } from "../icon-button/icon-button";

export const Github: React.FC = () => (
<>
<a href={config.GITHUB_LINK} target="_blank" rel="noopener noreferrer">
<a
href={config.GITHUB_LINK}
target="_blank"
rel="noopener noreferrer"
title={"Link to our GitHub Repo"}
>
<IconButton label="Github">
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down
11 changes: 8 additions & 3 deletions components/screens/home/twitch-panel/channel-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BackgroundImage, Text, Box, Flex } from "@mantine/core";
import { IconCircle } from "@tabler/icons-react";
import { useState } from "react";
import { TwitchStream } from "../../../../src/coh3/coh3-types";
import { isMobileCheck } from "../../../../src/utils";

type Props = {
twitchStreams: TwitchStream[];
Expand All @@ -13,6 +14,8 @@ const ChannelList = ({ onChangeChannel, twitchStreams }: Props) => {
onChangeChannel(idx);
setSelected(idx);
}
const isMobile = isMobileCheck();

return (
<Flex
style={{
Expand All @@ -23,6 +26,10 @@ const ChannelList = ({ onChangeChannel, twitchStreams }: Props) => {
h="100%"
>
{twitchStreams.slice(0, 3).map((stream: TwitchStream, idx: number) => {
const streamThumbnail = isMobile
? stream.thumbnail_url.replace("{width}", "200").replace("{height}", "109")
: stream.thumbnail_url.replace("{width}", "640").replace("{height}", "380");

return (
<Box
w={{
Expand All @@ -46,9 +53,7 @@ const ChannelList = ({ onChangeChannel, twitchStreams }: Props) => {
aspectRatio: 16 / 9,
width: "100%",
}}
src={`${stream.thumbnail_url
.replace("{width}", "1280")
.replace("{height}", "720")}`}
src={`${streamThumbnail}`}
>
<Flex pos="absolute" bottom={5} left={0} w="100%" justify="space-between" px={10}>
<Flex align="center" gap={4}>
Expand Down
8 changes: 4 additions & 4 deletions components/screens/home/twitch-panel/twitch-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Grid, Group, MediaQuery, Stack, Text, useMantineColorScheme } from "@ma
import { IconCircle } from "@tabler/icons-react";
import { TwitchStream } from "../../../../src/coh3/coh3-types";
import ChannelList from "./channel-list";
import { mobileCheck } from "../../../../src/utils";
import { isMobileCheck } from "../../../../src/utils";
import config from "../../../../config";

declare global {
Expand Down Expand Up @@ -55,7 +55,7 @@ const TwitchPanel = ({ twitchStreams }: Props) => {
const player = embed.getPlayer();
// maybe unneeded because of option above but can't hurt
player.setMuted(true);
if (!mobileCheck() && !config.isDevEnv()) player.play();
if (!isMobileCheck() && !config.isDevEnv()) player.play();
setPlayer(player);
});
});
Expand All @@ -69,8 +69,8 @@ const TwitchPanel = ({ twitchStreams }: Props) => {
function handleChangeChannel(channelIndex: number) {
if (!twitchStreams) return;
setCurrentChannelIndex(channelIndex);
player.setChannel(twitchStreams[channelIndex].user_login);
player.play();
player?.setChannel(twitchStreams[channelIndex].user_login);
player?.play();
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const PlayerStandingsTable = ({
startPosition,
platform,
)}
rel="nofollow"
title={"Link to Leaderboard with current player standings"}
>
{rank}
</Anchor>
Expand Down
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const nextConfig = {
// All the images are served from the CF CDN, so we don't need to optimize them.
unoptimized: true,
},
i18n: {
locales: ["en"],
defaultLocale: "en",
},
};

const withEdgioConfig = withEdgio(
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const getIconsPathOnCDN = (

// https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser/11381730#11381730
// prettier-ignore
const mobileCheck = () => {
const isMobileCheck = () => {
let check = false;
(function (a) {
if (
Expand All @@ -79,5 +79,5 @@ export {
isBrowserEnv,
getIconsPathOnCDN,
internalSlash,
mobileCheck,
isMobileCheck,
};

0 comments on commit 69731dc

Please sign in to comment.