This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
index.js
104 lines (98 loc) · 3.18 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import React from 'react'
import { Link, graphql } from 'gatsby'
import get from 'lodash/get'
import Helmet from 'react-helmet'
import Layout from '../components/layout'
import { rhythm, scale } from '../utils/typography'
import favicon from '../../static/img/favicon.ico'
class BlogIndex extends React.Component {
render() {
const siteTitle = get(this, 'props.data.site.siteMetadata.title')
const siteDescription = get(
this,
'props.data.site.siteMetadata.description'
)
const siteAnalytics = get(this, 'props.data.site.siteMetadata.googleAnalyticsId')
const posts = get(this, 'props.data.allMarkdownRemark.edges')
return (
<Layout location={this.props.location}>
<Helmet
htmlAttributes={{ lang: 'en' }}
meta={[{ name: 'description', content: siteDescription }]}
title={siteTitle}
link={[{ rel: 'shortcut icon', type: 'image/png', href: `${favicon}` }]}
>
{/* Digital Analytics Program roll-up, see the data at https://analytics.usa.gov */}
<script src="https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js" id="_fed_an_ua_tag"></script>
{siteAnalytics &&
<script>
{"(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', '"+siteAnalytics+"', 'auto');ga('set', 'anonymizeIp', true);ga('set', 'forceSSL', true);ga('send', 'pageview');"}
</script>
}
</Helmet>
{posts.map(({ node }) => {
const title = get(node, 'frontmatter.title') || node.fields.slug
return (
<div
style={{
marginBottom: rhythm(1.2),
}}
key={node.fields.slug}>
<h2
style={{
marginBottom: rhythm(-0.1),
}}
>
<Link
style={{
boxShadow: 'none',
textDecoration: 'none',
}}
to={node.fields.slug}>
{title}
</Link>
</h2>
<small
style={{
color: '#768d99',
}}
>{node.frontmatter.date}</small>
<p
style={{
marginTop: rhythm(.3),
}}
>{node.frontmatter.excerpt}</p>
</div>
)
})}
</Layout>
)
}
}
export default BlogIndex
export const pageQuery = graphql`
query {
site {
siteMetadata {
title
description
googleAnalyticsId
}
}
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
edges {
node {
excerpt
fields {
slug
}
frontmatter {
date(formatString: "MMMM D, YYYY")
title
excerpt
}
}
}
}
}
`