Commit 8edc6e6 1 parent 5b173e9 commit 8edc6e6 Copy full SHA for 8edc6e6
File tree 3 files changed +34
-52
lines changed
templates/PostListTemplate
3 files changed +34
-52
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import { graphql } from 'gatsby'
3
- import PostList from '../../components/PostList' ;
3
+ import moment from 'moment'
4
+ import Layout from '../../components/Layout'
5
+ import PostListHeader from '../../components/PostListHeader'
6
+ import PostListItem from '../../components/PostListItem'
7
+ import { GlobalLinks } from '../../consts/menuLinks'
8
+ import './style.scss'
4
9
5
10
class PostListTemplate extends React . Component {
6
11
render ( ) {
7
12
const { categoryId, categoryLabel } = this . props . pageContext
13
+ const posts = this . props . data . allMarkdownRemark . edges
8
14
15
+ const years = new Set ( )
16
+ let isFirst = true
17
+
18
+ const items = posts . map ( post => {
19
+ const year = moment ( post . node . frontmatter . date ) . year ( )
20
+ const showYear = ! years . has ( year )
21
+ years . add ( year )
22
+
23
+ const item = (
24
+ < PostListItem
25
+ data = { post }
26
+ key = { post . node . fields . slug }
27
+ showYear = { showYear }
28
+ isFirst = { isFirst }
29
+ />
30
+ )
31
+ isFirst = false
32
+
33
+ return item
34
+ } )
35
+
9
36
return (
10
- < PostList
11
- categoryId = { categoryId }
12
- pageTitle = { categoryLabel }
13
- { ...this . props }
14
- />
37
+ < Layout subtitle = { categoryLabel } globalLinkId = { GlobalLinks . Blog . id } >
38
+ < div className = "posts" >
39
+ < PostListHeader categoryId = { categoryId } />
40
+ { items }
41
+ </ div >
42
+ </ Layout >
15
43
)
16
44
}
17
45
}
File renamed without changes.
You can’t perform that action at this time.
0 commit comments