fix: don't prefetch as links enter viewport

This commit is contained in:
iCrawl
2022-08-26 12:00:25 +02:00
parent 13baf75cae
commit 682e0e1802
9 changed files with 19 additions and 19 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"

View File

@@ -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>
@@ -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"
@@ -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"
@@ -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>
@@ -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>

View File

@@ -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>
@@ -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>