forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (64 loc) · 2.23 KB
/
index.js
File metadata and controls
69 lines (64 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React, { Component } from "react"
import Helmet from "react-helmet"
import Layout from "../../components/layout"
import Unbird from "../../components/unbird"
import RRSM from "../../utils/reach-router-state-manager"
import queryString from "query-string"
import FilteredStarters from "./filtered-starters"
class StarterLibraryPage extends Component {
shouldComponentUpdate(nextProps) {
// prevent double render https://gatsbyjs.slack.com/archives/CA1GW1HNU/p1529615449000350
return JSON.stringify(this.props) !== JSON.stringify(nextProps)
}
render() {
const { location } = this.props
const urlState = queryString.parse(location.search)
const filtersApplied =
urlState.s !== undefined
? urlState.s // if theres a search term
: urlState.d && !Array.isArray(urlState.d)
? urlState.d // if theres a single dependency
: `Library` // if no search term or single dependency
return (
<Layout location={location}>
<Helmet>
<title>Starter Library</title>
<meta
name="description"
content={`Gatsby Starters: ${filtersApplied}`}
/>
<meta
property="og:description"
content={`Gatsby Starters: ${filtersApplied}`}
/>
<meta
name="twitter:description"
content={`Gatsby Starters: ${filtersApplied}`}
/>
<meta property="og:title" content={filtersApplied} />
<meta property="og:type" content="article" />
<meta name="twitter.label1" content="Reading time" />
<meta name="twitter:data1" content={`1 min read`} />
</Helmet>
<RRSM
{...this.props}
location={location}
render={({ setURLState, urlState }) => (
<FilteredStarters
{...this.props}
setURLState={setURLState}
urlState={urlState}
/>
)}
defaultSearchState={{ v: [`2`] }}
/>
<Unbird
dataSetId="5c113a828240aa564734d954"
publicKey="LCrEeIhIqPlNchPYkyXGww2azg5aCtC1"
feedbackPrompt="Have feedback on the Starter Library?"
/>
</Layout>
)
}
}
export default StarterLibraryPage