Skip to content

Commit a4d3691

Browse files
timothyisMatthew Sweeney
authored and
Matthew Sweeney
committed
Add back Automatic prerendering (#1257)
* Revert "Revert "Automatic prerendering (#1232)" (#1256)" This reverts commit fa59039. * Remove API page and add route
1 parent fa59039 commit a4d3691

26 files changed

+1314
-312
lines changed

components/code/inline-code.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const literal = '`'
2+
13
const InlineCode = ({ children, noWrap, color }) => (
24
<code className={noWrap && 'no-wrap'}>
35
{children}
@@ -17,11 +19,11 @@ const InlineCode = ({ children, noWrap, color }) => (
1719
}
1820
1921
code::before {
20-
content: '\`';
22+
content: '${literal}';
2123
}
2224
2325
code::after {
24-
content: '\`';
26+
content: '${literal}';
2527
}
2628
`}
2729
</style>

components/feedback-input/header-feedback.js

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

236237
return (
237238
<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 prefetch href="/" as="/home">
18+
<Link href="/" as="/home">
1919
<a>Home</a>
2020
</Link>
2121
</li>
2222
<li className="about">
23-
<Link prefetch href="/about">
23+
<Link href="/about">
2424
<a>About</a>
2525
</Link>
2626
</li>
2727
<li className="careers">
28-
<Link prefetch href="/careers">
28+
<Link href="/careers">
2929
<a>Careers</a>
3030
</Link>
3131
</li>
3232
<li className="blog">
33-
<Link prefetch href="/blog">
33+
<Link href="/blog">
3434
<a>Blog</a>
3535
</Link>
3636
</li>
3737
<li className="day">
38-
<Link prefetch href="/day">
38+
<Link 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 prefetch href="/pricing">
49+
<Link href="/pricing">
5050
<a>Pricing</a>
5151
</Link>
5252
<span>{'/'}</span>
53-
<Link prefetch href="/pricing/calculator">
53+
<Link href="/pricing/calculator">
5454
<a>Calculator</a>
5555
</Link>
5656
</li>
5757
<li className="now-for-github">
58-
<Link prefetch href="/github">
58+
<Link href="/github">
5959
<a>Now for GitHub</a>
6060
</Link>
6161
</li>
6262
<li className="now-for-gitlab">
63-
<Link prefetch href="/gitlab">
63+
<Link href="/gitlab">
6464
<a>Now for GitLab</a>
6565
</Link>
6666
</li>
6767
<li>
68-
<Link prefetch href="/smart-cdn">
68+
<Link href="/smart-cdn">
6969
<a>Smart CDN</a>
7070
</Link>
7171
</li>
7272
<li>
73-
<Link prefetch href="/integrations">
73+
<Link 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 prefetch href="/tv">
93+
<Link 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 prefetch href="/oss">
101+
<Link href="/oss">
102102
<a>Open Source Software</a>
103103
</Link>
104104
</li>
105105
<li className="design">
106-
<Link prefetch href="/design">
106+
<Link href="/design">
107107
<a>Design Assets</a>
108108
</Link>
109109
</li>
110110

111111
<li className="security">
112-
<Link prefetch href="/security">
112+
<Link href="/security">
113113
<a>Security</a>
114114
</Link>
115115
</li>
116116
<li className="support">
117-
<Link prefetch href="/support">
117+
<Link 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 prefetch href="/privacy">
127+
<Link href="/privacy">
128128
<a>Privacy Policy</a>
129129
</Link>
130130
</li>
131131
<li className="terms">
132-
<Link prefetch href="/terms">
132+
<Link 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 prefetch href="/docs">
171+
<Link 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 prefetch href="/docs/api">
178+
<Link 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 prefetch href="/examples">
185+
<Link 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} prefetch>
68+
<Link href={href} as={as}>
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} prefetch>
86+
<Link href={href} as={as}>
8787
<a
8888
className={cns('title', { active })}
8989
onClick={this.handleClick}

components/layout/navbar/desktop.js

+4-8
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'
23
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,13 +311,9 @@ export class NavLink extends React.Component {
311311
{info.name}
312312
</a>
313313
) : (
314-
<LinkWithHoverPrefetch
315-
href={info.href}
316-
as={info.as || info.href}
317-
onClick={onClick}
318-
>
319-
{info.name}
320-
</LinkWithHoverPrefetch>
314+
<Link href={info.href} as={info.as || info.href}>
315+
<a onClick={onClick}>{info.name}</a>
316+
</Link>
321317
)}
322318
<style jsx>{`
323319
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} prefetch>
7+
<Link href={href}>
88
<span className="active-button">
99
{children}
1010
<style jsx>{`

components/search/autocomplete.js

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

components/text/code.js

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

60+
const literal = '`'
61+
6062
export const InlineCode = ({ children, noWrap, color }) => (
6163
<code className={noWrap && 'no-wrap'}>
6264
{children}
@@ -76,11 +78,11 @@ export const InlineCode = ({ children, noWrap, color }) => (
7678
}
7779
7880
code::before {
79-
content: '\`';
81+
content: '${literal}';
8082
}
8183
8284
code::after {
83-
content: '\`';
85+
content: '${literal}';
8486
}
8587
`}
8688
</style>

components/text/link.js

+4-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { Component } from 'react'
2-
import { withRouter } from 'next/router'
3-
import NativeLink from 'next/link'
1+
import Link from 'next/link'
42
import cn from 'classnames'
53
import PropTypes from 'prop-types'
64
import CircledQuestion from '~/components/icons/circled-question'
@@ -33,9 +31,9 @@ export const InternalLink = ({
3331
hover
3432
}) => (
3533
<span className={cn({ 'no-underline': !underlineOnHover })}>
36-
<LinkWithHoverPrefetch href={href} as={as} onClick={onClick}>
37-
{children}
38-
</LinkWithHoverPrefetch>
34+
<Link href={href} as={as}>
35+
<a onClick={onClick}>{children}</a>
36+
</Link>
3937
<style jsx>{`
4038
span :global(a) {
4139
text-decoration: none;
@@ -446,22 +444,6 @@ IconExternalLink.contextTypes = {
446444
disabled: PropTypes.bool
447445
}
448446

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-
465447
export const HelpLink = ({ children, href, hasIcon, ...props }) => (
466448
<a href={href} {...props} className={hasIcon ? 'icon' : ''}>
467449
<span>{children}</span>
@@ -496,5 +478,3 @@ export const HelpLink = ({ children, href, hasIcon, ...props }) => (
496478
`}</style>
497479
</a>
498480
)
499-
500-
export const LinkWithHoverPrefetch = withRouter(HoverPrefetchLink)

components/topics/topic.js

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1+
import Link from 'next/link'
12
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-
<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} />
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+
)
1719
)
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>
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>
2931
</Link>
3032
<style jsx>{`
3133
.topic :global(a) {

0 commit comments

Comments
 (0)