Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions build-cards.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const glob = require('glob')
const { chromium } = require('playwright')
const { chromium, devices } = require('playwright')

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

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

async function getScreenshot(postId) {
const width = 1200
const height = 630
const browser = await chromium.launch()
const context = await browser.newContext({ deviceScaleFactor: 2 })
const context = await browser.newContext({ ...device, deviceScaleFactor: 2 })
const page = await context.newPage()

await page.setViewportSize({
width: width,
height: height,
})
await page.goto(`${baseUrl}/cards/${postId}`)
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.

Expand Down
Binary file modified public/cards/czi-eoss-grant-conclusion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions src/pages/cards/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ import matter from 'gray-matter'
import path from 'path'

const Card = ({ frontmatter, id }) => {
const boxBackground = 'gray.300'
const boxBackground = 'teal.100'
const date = new Date(frontmatter.date)

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

<Stack direction={'row'} my={4} align={'center'}>
<Icon as={MdOutlineCalendarToday} w='8' h='8' />
<Text>{formatDate(date)}</Text>
<Text fontWeight={'bold'}>{formatDate(date)}</Text>
</Stack>

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