Skip to content

Commit 690c113

Browse files
Add hover animation to post summaries. Fix key error for post list item groups
1 parent 655aa0a commit 690c113

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

web/pages/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const PostContainer = styled.li`
1212
padding: 7px 10px;
1313
font-size: 1.75em;
1414
background-color: ${({ theme }) => theme.listItemBgColor};
15+
transition: background 300ms;
1516
&:hover {
1617
cursor: pointer;
17-
background-color: ${({ theme }) => theme.secondaryColor};
18+
background: ${({ theme }) => theme.secondaryColor};
1819
border: ${({ theme }) => theme.secondaryColor};
1920
}
2021
`
@@ -87,9 +88,7 @@ function Index({
8788

8889
useEffect(() => {
8990
getTagCountsData(tags)
90-
.then(tagCounts => {
91-
setTagCounts(tagCounts)
92-
})
91+
.then(tagCounts => setTagCounts(tagCounts))
9392
.catch(err => console.log('error getting tag counts: ', err))
9493
}, [])
9594

web/pages/posts/[slug].js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,19 +314,22 @@ function Post(props) {
314314
}
315315
// TODO: test if list rendering works correctly with multiple lists in post
316316
let list = []
317+
let listGroupKey = ''
317318
props.body && props.body.forEach(section => {
318319
// console.log('section: ', section)
319320
if (section.listItem) {
320321
list.push(
321322
<ListItem key={section._key}>{formatListItem(section.children)}</ListItem>
322323
)
324+
listGroupKey += section._key
323325
} else {
324326
if (list.length > 0) {
325327
postContent.push(
326-
// TODO: why is React key error being thrown here?
327-
<UL>{list}</UL>
328+
// TODO: why is key needed on this UL here?
329+
<UL key={listGroupKey}>{list}</UL>
328330
)
329331
list = []
332+
listGroupKey = ''
330333
}
331334
switch(section._type) {
332335
case 'block':

0 commit comments

Comments
 (0)