Skip to content

Commit fa59039

Browse files
Matthew Sweeneytimothyis
Matthew Sweeney
authored andcommitted
Revert "Automatic prerendering (#1232)" (#1256)
This reverts commit f0ea0ea.
1 parent f0ea0ea commit fa59039

25 files changed

+309
-1309
lines changed

components/code/inline-code.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const literal = '`'
2-
31
const InlineCode = ({ children, noWrap, color }) => (
42
<code className={noWrap && 'no-wrap'}>
53
{children}
@@ -19,11 +17,11 @@ const InlineCode = ({ children, noWrap, color }) => (
1917
}
2018
2119
code::before {
22-
content: '${literal}';
20+
content: '\`';
2321
}
2422
2523
code::after {
26-
content: '${literal}';
24+
content: '\`';
2725
}
2826
`}
2927
</style>

components/feedback-input/header-feedback.js

-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ class HeaderFeedback extends Component {
232232
const { focused } = this.state
233233
delete props.onFeedback
234234
delete props.textAreaStyle
235-
delete props.hideHeader
236235

237236
return (
238237
<ClickOutside

components/footer/index.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ const Footer = ({ className }) => {
1515
<ul className="navigation">
1616
<li className="links-title">Company</li>
1717
<li className="home">
18-
<Link href="/" as="/home">
18+
<Link prefetch href="/" as="/home">
1919
<a>Home</a>
2020
</Link>
2121
</li>
2222
<li className="about">
23-
<Link href="/about">
23+
<Link prefetch href="/about">
2424
<a>About</a>
2525
</Link>
2626
</li>
2727
<li className="careers">
28-
<Link href="/careers">
28+
<Link prefetch href="/careers">
2929
<a>Careers</a>
3030
</Link>
3131
</li>
3232
<li className="blog">
33-
<Link href="/blog">
33+
<Link prefetch href="/blog">
3434
<a>Blog</a>
3535
</Link>
3636
</li>
3737
<li className="day">
38-
<Link href="/day">
38+
<Link prefetch href="/day">
3939
<a>ZEIT Day</a>
4040
</Link>
4141
</li>
@@ -46,31 +46,31 @@ const Footer = ({ className }) => {
4646
<a href="/download">Download</a>
4747
</li>
4848
<li className="pricing">
49-
<Link href="/pricing">
49+
<Link prefetch href="/pricing">
5050
<a>Pricing</a>
5151
</Link>
5252
<span>{'/'}</span>
53-
<Link href="/pricing/calculator">
53+
<Link prefetch href="/pricing/calculator">
5454
<a>Calculator</a>
5555
</Link>
5656
</li>
5757
<li className="now-for-github">
58-
<Link href="/github">
58+
<Link prefetch href="/github">
5959
<a>Now for GitHub</a>
6060
</Link>
6161
</li>
6262
<li className="now-for-gitlab">
63-
<Link href="/gitlab">
63+
<Link prefetch href="/gitlab">
6464
<a>Now for GitLab</a>
6565
</Link>
6666
</li>
6767
<li>
68-
<Link href="/smart-cdn">
68+
<Link prefetch href="/smart-cdn">
6969
<a>Smart CDN</a>
7070
</Link>
7171
</li>
7272
<li>
73-
<Link href="/integrations">
73+
<Link prefetch href="/integrations">
7474
<a>Integrations Marketplace</a>
7575
</Link>
7676
</li>
@@ -90,31 +90,31 @@ const Footer = ({ className }) => {
9090
<a href="/examples">Examples</a>
9191
</li>
9292
<li className="tv">
93-
<Link href="/tv">
93+
<Link prefetch href="/tv">
9494
<a>TV</a>
9595
</Link>
9696
</li>
9797
</ul>
9898
<ul className="navigation">
9999
<li className="links-title">More</li>
100100
<li className="oss">
101-
<Link href="/oss">
101+
<Link prefetch href="/oss">
102102
<a>Open Source Software</a>
103103
</Link>
104104
</li>
105105
<li className="design">
106-
<Link href="/design">
106+
<Link prefetch href="/design">
107107
<a>Design Assets</a>
108108
</Link>
109109
</li>
110110

111111
<li className="security">
112-
<Link href="/security">
112+
<Link prefetch href="/security">
113113
<a>Security</a>
114114
</Link>
115115
</li>
116116
<li className="support">
117-
<Link href="/support">
117+
<Link prefetch href="/support">
118118
<a>Support</a>
119119
</Link>
120120
</li>
@@ -124,12 +124,12 @@ const Footer = ({ className }) => {
124124
<li className="links-title" />
125125

126126
<li className="privacy">
127-
<Link href="/privacy">
127+
<Link prefetch href="/privacy">
128128
<a>Privacy Policy</a>
129129
</Link>
130130
</li>
131131
<li className="terms">
132-
<Link href="/terms">
132+
<Link prefetch href="/terms">
133133
<a>Terms of Service</a>
134134
</Link>
135135
</li>

components/layout/docs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,21 @@ class withDoc extends React.Component {
168168
!router.pathname.startsWith('/docs/api')
169169
}
170170
>
171-
<Link href="/docs">
171+
<Link prefetch href="/docs">
172172
<a onClick={this.handleIndexClick}>Docs</a>
173173
</Link>
174174
</ToggleItem>
175175
<ToggleItem
176176
active={router.pathname.startsWith('/docs/api')}
177177
>
178-
<Link href="/docs/api">
178+
<Link prefetch href="/docs/api">
179179
<a onClick={this.handleIndexClick}>API Reference</a>
180180
</Link>
181181
</ToggleItem>
182182
<ToggleItem
183183
active={router.pathname.startsWith('/examples')}
184184
>
185-
<Link href="/examples">
185+
<Link prefetch href="/examples">
186186
<a onClick={this.handleIndexClick}>Examples</a>
187187
</Link>
188188
</ToggleItem>

components/layout/index/entry-index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class EntryIndex extends Component {
6565
{entry.title}
6666
</a>
6767
) : (
68-
<Link href={href} as={as}>
68+
<Link href={href} as={as} prefetch>
6969
<a
7070
className={cns({ active: isEntryActive(this.props) })}
7171
onClick={this.handleClick}

components/layout/index/section-index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SectionIndex extends Component {
8383
{section.title}
8484
</a>
8585
) : (
86-
<Link href={href} as={as}>
86+
<Link href={href} as={as} prefetch>
8787
<a
8888
className={cns('title', { active })}
8989
onClick={this.handleClick}

components/layout/navbar/desktop.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useEffect } from 'react'
2-
import Link from 'next/link'
32
import cn from 'classnames'
3+
import { LinkWithHoverPrefetch } from '~/components/text/link'
44
import qs from 'querystring'
55
import { parse } from 'url'
66
import _scrollIntoViewIfNeeded from 'scroll-into-view-if-needed'
@@ -311,9 +311,13 @@ export class NavLink extends React.Component {
311311
{info.name}
312312
</a>
313313
) : (
314-
<Link href={info.href} as={info.as || info.href}>
315-
<a onClick={onClick}>{info.name}</a>
316-
</Link>
314+
<LinkWithHoverPrefetch
315+
href={info.href}
316+
as={info.as || info.href}
317+
onClick={onClick}
318+
>
319+
{info.name}
320+
</LinkWithHoverPrefetch>
317321
)}
318322
<style jsx>{`
319323
div.selected {

components/layout/navbar/toggle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Link from 'next/link'
44

55
const ActivePageButton = withRouter(({ children, router, href }) => {
66
return (
7-
<Link href={href}>
7+
<Link href={href} prefetch>
88
<span className="active-button">
99
{children}
1010
<style jsx>{`

components/search/autocomplete.js

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class AutoComplete extends Component {
8080
href={`${hit.url}?query=${encodeURIComponent(this.state.value)}${
8181
hit.anchor ? `${hit.anchor}` : ''
8282
}`}
83+
prefetch
8384
>
8485
<a>
8586
<span className="suggestion__title">

components/text/code.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Code.contextTypes = {
5757
darkBg: PropTypes.bool
5858
}
5959

60-
const literal = '`'
61-
6260
export const InlineCode = ({ children, noWrap, color }) => (
6361
<code className={noWrap && 'no-wrap'}>
6462
{children}
@@ -78,11 +76,11 @@ export const InlineCode = ({ children, noWrap, color }) => (
7876
}
7977
8078
code::before {
81-
content: '${literal}';
79+
content: '\`';
8280
}
8381
8482
code::after {
85-
content: '${literal}';
83+
content: '\`';
8684
}
8785
`}
8886
</style>

components/text/link.js

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import Link from 'next/link'
1+
import { Component } from 'react'
2+
import { withRouter } from 'next/router'
3+
import NativeLink from 'next/link'
24
import cn from 'classnames'
35
import PropTypes from 'prop-types'
46
import CircledQuestion from '~/components/icons/circled-question'
@@ -31,9 +33,9 @@ export const InternalLink = ({
3133
hover
3234
}) => (
3335
<span className={cn({ 'no-underline': !underlineOnHover })}>
34-
<Link href={href} as={as}>
35-
<a onClick={onClick}>{children}</a>
36-
</Link>
36+
<LinkWithHoverPrefetch href={href} as={as} onClick={onClick}>
37+
{children}
38+
</LinkWithHoverPrefetch>
3739
<style jsx>{`
3840
span :global(a) {
3941
text-decoration: none;
@@ -444,6 +446,22 @@ IconExternalLink.contextTypes = {
444446
disabled: PropTypes.bool
445447
}
446448

449+
class HoverPrefetchLink extends Component {
450+
render() {
451+
const { children, router, onClick, ...rest } = this.props
452+
return (
453+
<NativeLink {...rest}>
454+
<a
455+
onMouseEnter={() => router.prefetch(this.props.href)}
456+
onClick={onClick}
457+
>
458+
{children}
459+
</a>
460+
</NativeLink>
461+
)
462+
}
463+
}
464+
447465
export const HelpLink = ({ children, href, hasIcon, ...props }) => (
448466
<a href={href} {...props} className={hasIcon ? 'icon' : ''}>
449467
<span>{children}</span>
@@ -478,3 +496,5 @@ export const HelpLink = ({ children, href, hasIcon, ...props }) => (
478496
`}</style>
479497
</a>
480498
)
499+
500+
export const LinkWithHoverPrefetch = withRouter(HoverPrefetchLink)

components/topics/topic.js

+21-23
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
import Link from 'next/link'
21
import { H5 } from '~/components/text'
2+
import { LinkWithHoverPrefetch as Link } from '~/components/text/link'
33

44
export default function Topic({ topic, icons, href }) {
55
return (
66
<div className="topic">
77
<Link href={href}>
8-
<a>
9-
<span className="topic-icons">
10-
{Array.isArray(icons) ? (
11-
icons.map(icon =>
12-
typeof icon === 'object' ? (
13-
<span key={icon.src} style={{ backgroundColor: icon.color }}>
14-
<img alt={`Icon for ${topic}`} src={icon.src} />
15-
</span>
16-
) : (
17-
<img alt={`Icon for ${topic}`} key={icon} src={icon} />
18-
)
8+
<span className="topic-icons">
9+
{Array.isArray(icons) ? (
10+
icons.map(icon =>
11+
typeof icon === 'object' ? (
12+
<span key={icon.src} style={{ backgroundColor: icon.color }}>
13+
<img alt={`Icon for ${topic}`} src={icon.src} />
14+
</span>
15+
) : (
16+
<img alt={`Icon for ${topic}`} key={icon} src={icon} />
1917
)
20-
) : typeof icons === 'object' ? (
21-
<span style={{ backgroundColor: icons.color }}>
22-
<img alt={`Icon for ${topic}`} src={icons.src} />
23-
</span>
24-
) : (
25-
<img alt={`Icon for ${topic}`} src={icons} />
26-
)}
27-
</span>
28-
<H5>{topic}</H5>
29-
<span className="note">Read the guide</span>
30-
</a>
18+
)
19+
) : typeof icons === 'object' ? (
20+
<span style={{ backgroundColor: icons.color }}>
21+
<img alt={`Icon for ${topic}`} src={icons.src} />
22+
</span>
23+
) : (
24+
<img alt={`Icon for ${topic}`} src={icons} />
25+
)}
26+
</span>
27+
<H5>{topic}</H5>
28+
<span className="note">Read the guide</span>
3129
</Link>
3230
<style jsx>{`
3331
.topic :global(a) {

0 commit comments

Comments
 (0)