-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
index.js
50 lines (47 loc) · 1.68 KB
/
index.js
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
import React, { Component } from "react"
import Helmet from "react-helmet"
import Layout from "../../components/layout"
import RRSM from "../../utils/reach-router-state-manager"
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, urlState } = this.props
const filtersApplied =
urlState.s !== ``
? urlState.s // if theres a search term
: urlState.d && !Array.isArray(urlState.d)
? urlState.d // if theres a single dependency
: `Showcase` // 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>
<FilteredStarters {...this.props} />
</Layout>
)
}
}
export default RRSM({ s: ``, c: [], d: [], v: [], sort: `recent` })(
StarterLibraryPage
)