Skip to content

Commit f2da25e

Browse files
authored
use desktop context (#321)
1 parent 0c1f6fb commit f2da25e

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

build-cards.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('fs')
22
const glob = require('glob')
3-
const { chromium } = require('playwright')
3+
const { chromium, devices } = require('playwright')
44

55
const { getAllPostsIds } = require('./src/lib/posts')
66
const cardsDir = './public/cards/'
@@ -20,18 +20,13 @@ glob('./cards/**.png', async (err, files) => {
2020
})
2121

2222
const baseUrl = process.env.CARDS_BASE_URL || 'http://localhost:3000'
23+
const device = devices['Desktop Safari']
2324

2425
async function getScreenshot(postId) {
25-
const width = 1200
26-
const height = 630
2726
const browser = await chromium.launch()
28-
const context = await browser.newContext({ deviceScaleFactor: 2 })
27+
const context = await browser.newContext({ ...device, deviceScaleFactor: 2 })
2928
const page = await context.newPage()
3029

31-
await page.setViewportSize({
32-
width: width,
33-
height: height,
34-
})
3530
await page.goto(`${baseUrl}/cards/${postId}`)
3631
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.
3732

2.71 KB
Loading

src/pages/cards/[id].js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,21 @@ import matter from 'gray-matter'
1919
import path from 'path'
2020

2121
const Card = ({ frontmatter, id }) => {
22-
const boxBackground = 'gray.300'
22+
const boxBackground = 'teal.100'
2323
const date = new Date(frontmatter.date)
2424

2525
return (
26-
<Box sx={{ bg: boxBackground, color: 'invert' }} h={'100vh'} w={'100vw'}>
27-
<Container id='post' maxW={{ base: '900px', md: '930px' }}>
26+
<Box
27+
sx={{ bg: boxBackground, color: 'invert' }}
28+
h={'100vh'}
29+
w={'100vw'}
30+
backgroundImage={'/background.svg'}
31+
>
32+
<Container id='post' maxW={'container.lg'} centerContent>
2833
<Flex direction='column' fontSize={'2xl'}>
2934
<Stack direction={'row'} spacing={8} justify='space-between'>
3035
<Stack>
31-
<Text my={8} fontWeight={'bold'} opacity={0.7}>
36+
<Text my={32} fontWeight={'bold'} opacity={0.7}>
3237
xarray.dev / blog
3338
</Text>
3439
</Stack>
@@ -53,7 +58,7 @@ const Card = ({ frontmatter, id }) => {
5358

5459
<Stack direction={'row'} my={4} align={'center'}>
5560
<Icon as={MdOutlineCalendarToday} w='8' h='8' />
56-
<Text>{formatDate(date)}</Text>
61+
<Text fontWeight={'bold'}>{formatDate(date)}</Text>
5762
</Stack>
5863

5964
<Stack direction={'row'} my={8} align={'center'}>

0 commit comments

Comments
 (0)