Skip to content

Commit

Permalink
fix: don't prefetch as links enter viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Aug 26, 2022
1 parent 13baf75 commit 682e0e1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/website/src/components/HyperlinkedText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function HyperlinkedText({ tokens }: { tokens: TokenDocumentation[] }) {
{tokens.map((token, idx) => {
if (token.path) {
return (
<Link key={idx} href={token.path} passHref>
<Link key={idx} href={token.path} passHref prefetch={false}>
<Anchor component="a" inherit>
{token.text}
</Anchor>
Expand Down
2 changes: 1 addition & 1 deletion packages/website/src/components/InheritanceText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function InheritanceText({ data }: { data: InheritanceData }) {
return (
<Text weight={600}>
{'Inherited from '}
<Link href={data.path} passHref>
<Link href={data.path} passHref prefetch={false}>
<Anchor component="a" className="font-mono">
{data.parentName}
</Anchor>
Expand Down
2 changes: 1 addition & 1 deletion packages/website/src/components/SidebarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function SidebarItems({
.map((group, idx) => (
<Section key={idx} title={group} icon={resolveIcon(group)}>
{groupItems[group].map((member, i) => (
<Link key={i} href={member.path} passHref>
<Link key={i} href={member.path} passHref prefetch={false}>
<NavLink
className={classes.link}
component="a"
Expand Down
16 changes: 8 additions & 8 deletions packages/website/src/components/SidebarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export function SidebarLayout({
const breadcrumbs = useMemo(
() =>
asPathWithoutQueryAndAnchor.split('/').map((path, idx, original) => (
<Link key={idx} href={original.slice(0, idx + 1).join('/')} passHref>
<Link key={idx} href={original.slice(0, idx + 1).join('/')} passHref prefetch={false}>
<Anchor component="a" sx={(theme) => ({ color: theme.colorScheme === 'dark' ? theme.white : theme.black })}>
{path}
</Anchor>
Expand Down Expand Up @@ -317,7 +317,7 @@ export function SidebarLayout({
</MediaQuery>
</Box>
<Group>
<Link href="https://github.com/discordjs/discord.js" passHref>
<Link href="https://github.com/discordjs/discord.js" passHref prefetch={false}>
<ActionIcon
component="a"
target="_blank"
Expand Down Expand Up @@ -356,7 +356,7 @@ export function SidebarLayout({
>
<Container>
<Box className={classes.links}>
<Link href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss" passHref>
<Link href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss" prefetch={false}>
<a title="Vercel">
<Image
src="/powered-by-vercel.svg"
Expand All @@ -371,12 +371,12 @@ export function SidebarLayout({
<Stack spacing={8}>
<Title order={4}>Community</Title>
<Stack spacing={0}>
<Link href="https://discord.gg/djs" passHref>
<Link href="https://discord.gg/djs" passHref prefetch={false}>
<Anchor component="a" target="_blank" rel="noopener noreferrer" className={classes.link}>
Discord
</Anchor>
</Link>
<Link href="https://github.com/discordjs/discord.js/discussions" passHref>
<Link href="https://github.com/discordjs/discord.js/discussions" passHref prefetch={false}>
<Anchor component="a" target="_blank" rel="noopener noreferrer" className={classes.link}>
GitHub discussions
</Anchor>
Expand All @@ -386,17 +386,17 @@ export function SidebarLayout({
<Stack spacing={8}>
<Title order={4}>Project</Title>
<Stack spacing={0}>
<Link href="https://github.com/discordjs/discord.js" passHref>
<Link href="https://github.com/discordjs/discord.js" passHref prefetch={false}>
<Anchor component="a" target="_blank" rel="noopener noreferrer" className={classes.link}>
discord.js
</Anchor>
</Link>
<Link href="https://discordjs.guide" passHref>
<Link href="https://discordjs.guide" passHref prefetch={false}>
<Anchor component="a" target="_blank" rel="noopener noreferrer" className={classes.link}>
discord.js guide
</Anchor>
</Link>
<Link href="https://discord-api-types.dev" passHref>
<Link href="https://discord-api-types.dev" passHref prefetch={false}>
<Anchor component="a" target="_blank" rel="noopener noreferrer" className={classes.link}>
discord-api-types
</Anchor>
Expand Down
4 changes: 2 additions & 2 deletions packages/website/src/components/tsdoc/TSDoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function TSDoc({ node }: { node: AnyDocNodeJSON }): JSX.Element {

if (codeDestination) {
return (
<Link key={idx} href={codeDestination.path} passHref>
<Link key={idx} href={codeDestination.path} passHref prefetch={false}>
<Anchor component="a" className="font-mono">
{text ?? codeDestination.name}
</Anchor>
Expand All @@ -51,7 +51,7 @@ export function TSDoc({ node }: { node: AnyDocNodeJSON }): JSX.Element {

if (urlDestination) {
return (
<Link key={idx} href={urlDestination} passHref>
<Link key={idx} href={urlDestination} passHref prefetch={false}>
<Anchor component="a" className="font-mono">
{text ?? urlDestination}
</Anchor>
Expand Down
2 changes: 1 addition & 1 deletion packages/website/src/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function FourOhFourPage() {
<Box className={classes.label}>404</Box>
<Title align="center">Not found.</Title>
<Group position="center">
<Link href="/docs/packages" passHref>
<Link href="/docs/packages" passHref prefetch={false}>
<Button component="a" variant="filled" size="md" mt="xl">
Take me back
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function VersionsRoute(props: Partial<VersionProps> & { error?: s
Select a version:
</Title>
{props.data?.versions.map((version) => (
<Link key={version} href={`/docs/packages/${props.packageName!}/${version}`} passHref>
<Link key={version} href={`/docs/packages/${props.packageName!}/${version}`} passHref prefetch={false}>
<UnstyledButton className={classes.control} component="a">
<Group position="apart">
<Group>
Expand Down
2 changes: 1 addition & 1 deletion packages/website/src/pages/docs/packages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function PackagesRoute() {
Select a package:
</Title>
{PACKAGES.map((pkg) => (
<Link key={pkg} href={`/docs/packages/${pkg}`} passHref>
<Link key={pkg} href={`/docs/packages/${pkg}`} passHref prefetch={false}>
<UnstyledButton className={classes.control} component="a">
<Group position="apart">
<Group>
Expand Down
6 changes: 3 additions & 3 deletions packages/website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ export default function IndexRoute() {
</Text>

<Group mt={30}>
<Link href="/docs" passHref>
<Link href="/docs" passHref prefetch={false}>
<Button component="a" radius="sm" size="md">
Docs
</Button>
</Link>
<Link href="https://discordjs.guide" passHref>
<Link href="https://discordjs.guide" passHref prefetch={false}>
<Button component="a" variant="default" radius="sm" size="md" rightIcon={<FiExternalLink />}>
Guide
</Button>
Expand Down Expand Up @@ -116,7 +116,7 @@ await client.login('token');`}
</Box>
</Box>
<Center>
<Link href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss">
<Link href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss" prefetch={false}>
<a title="Vercel">
<Image
src="/powered-by-vercel.svg"
Expand Down

1 comment on commit 682e0e1

@vercel
Copy link

@vercel vercel bot commented on 682e0e1 Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.