Skip to content

Commit d250e84

Browse files
authored
update social share cards (#318)
1 parent 7a85de2 commit d250e84

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

build-cards.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ async function getScreenshot(postId) {
3333
height: height,
3434
})
3535
await page.goto(`${baseUrl}/cards/${postId}`)
36+
await page.waitForTimeout(2000) // wait for page to load fully (2 seconds). This is a hacky way to wait for GitHub Avatars to fully load.
3637

3738
await page.screenshot({
3839
path: `${cardsDir}/${postId}.png`,
-22.1 KB
Loading

src/pages/cards/[id].js

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,89 @@
1+
import { Image } from '@/components/mdx'
2+
import { MdOutlineCalendarToday, MdPeopleOutline } from 'react-icons/md'
3+
14
import { formatDate } from '@/lib/date-formatting'
25
import { getAllPostsIds, getPostData } from '@/lib/posts'
36
import {
47
Avatar,
5-
AvatarGroup,
6-
Box,
7-
Center,
8+
Container,
89
Flex,
910
Heading,
1011
Icon,
11-
Image,
12+
Stack,
1213
Text,
14+
Wrap,
15+
WrapItem,
1316
} from '@chakra-ui/react'
1417
import fs from 'fs'
1518
import matter from 'gray-matter'
1619
import path from 'path'
17-
import { MdCalendarToday } from 'react-icons/md'
1820

1921
const Card = ({ frontmatter, id }) => {
20-
const boxBackground = 'white !important'
21-
const iconColor = 'brand.200'
22+
const boxBackground = 'gray.300'
2223
const date = new Date(frontmatter.date)
2324

2425
return (
25-
<Center mt={40} id='post'>
26-
<Flex
27-
borderRadius='20px'
28-
bg={boxBackground}
29-
w={{ base: '900px', md: '930px' }}
30-
direction='column'
31-
justify='space-between'
32-
>
33-
<Box p='20px'>
34-
<Flex w='100%' mb='10px'>
26+
<Container
27+
my={20}
28+
id='post'
29+
sx={{ bg: boxBackground, color: 'invert' }}
30+
maxW={{ base: '900px', md: '930px' }}
31+
>
32+
<Flex direction='column' fontSize={'2xl'}>
33+
<Stack direction={'row'} spacing={8} justify='space-between'>
34+
<Stack>
35+
<Text my={8} fontWeight={'bold'} opacity={0.5}>
36+
xarray.dev / blog
37+
</Text>
38+
</Stack>
39+
<Flex
40+
direction={'row'}
41+
alignItems={'center'}
42+
justify={'right'}
43+
align={'right'}
44+
>
3545
<Image
46+
justify={'right'}
47+
align={'right'}
48+
w={40}
3649
src={'/dataset-diagram-logo.png'}
3750
alt={'xarray logo'}
38-
me={'auto'}
39-
></Image>
40-
</Flex>
41-
<Box>
42-
<Heading as={'h1'} size='xl'>
43-
{frontmatter.title}
44-
</Heading>
45-
</Box>
46-
</Box>
47-
48-
<Flex
49-
mt='auto'
50-
justify='space-between'
51-
w='100%'
52-
align='center'
53-
borderBottomLeftRadius='inherit'
54-
borderBottomRightRadius='inherit'
55-
height='100%'
56-
direction='row'
57-
p='20px'
58-
>
59-
<Flex me='25px'>
60-
<Icon
61-
as={MdCalendarToday}
62-
w='20px'
63-
h='20px'
64-
me='6px'
65-
color='white.500'
6651
/>
67-
<Text fontWeight={'600'} fontSize={'xl'}>
68-
{formatDate(date)}
69-
</Text>
7052
</Flex>
53+
</Stack>
54+
<Heading as={'h1'} size={'2xl'} my={8}>
55+
{frontmatter.title}
56+
</Heading>
57+
58+
<Stack direction={'row'} my={4} align={'center'}>
59+
<Icon as={MdOutlineCalendarToday} w='8' h='8' />
60+
<Text>{formatDate(date)}</Text>
61+
</Stack>
62+
63+
<Stack direction={'row'} my={4} align={'center'}>
64+
<Icon as={MdPeopleOutline} w='8' h='8' />
7165

72-
<AvatarGroup size='md' max={4} color={iconColor}>
66+
<Wrap spacing={3} my={8}>
7367
{frontmatter.authors.map((author) => {
7468
return (
75-
<Avatar
76-
key={author.name}
77-
src={`https://github.com/${author.github}.png`}
78-
name={author.name}
79-
mt={1}
80-
fontWeight={'600'}
81-
/>
69+
<WrapItem key={author.name}>
70+
<Flex align={'center'} direction={'column'}>
71+
<Avatar
72+
src={`https://github.com/${author.github}.png`}
73+
name={author.name}
74+
size={'lg'}
75+
/>
76+
<Text fontWeight={'bold'} fontSize={'md'}>
77+
{author.name}
78+
</Text>
79+
</Flex>
80+
</WrapItem>
8281
)
8382
})}
84-
</AvatarGroup>
85-
</Flex>
83+
</Wrap>
84+
</Stack>
8685
</Flex>
87-
</Center>
86+
</Container>
8887
)
8988
}
9089

0 commit comments

Comments
 (0)