import { z } from 'zod'; import { getRandomColor } from '../../utils/getRandomColor'; import { NewsSchema } from '../../utils/schemas'; import Email from './template'; export default function NewsletterTemplate( stories: z.infer[] ) { const sayings = [ 'hot off the press', 'straight from the oven', "straight from the horse's mouth", 'brand spanking new', 'fresh as a daisy', 'straight out of the box', 'straight off the assembly line', 'hot out of the kitchen', 'just minted', 'freshly brewed', 'just off the production line' ]; return { subject: `What's new from Hackernews?`, template: (

Here is something{' '} {sayings[Math.floor(Math.random() * sayings.length)]}:

{stories.map(story => { const background = getRandomColor(); return (

{story.title}

by {story.by}

{story.text && (

500 ? story.text.substring(0, 500) + '...' : story.text }} />

)} {story.url && (
Read more
)}
); })} } /> ) }; }