import { hnEmail } from "https://esm.town/v/rodrigotello/hnEmail";
import { email } from "https://esm.town/v/std/email?v=9";
import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
export default async function({ lastRunAt }) {
let posts = await hnLatestPosts({
query: "AI, LLM",
search_by_date: true,
});
for (let post of posts) {
let res = await fetch(`https://hacker-news.firebaseio.com/v0/item/${post.objectID}.json`);
post.upvotes = await res.json();
}
let { html, subject } = await hnEmail({ posts });
console.log(posts);
if (posts.length)
await email({ html, subject });
}