Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { truncateString } from "https://esm.town/v/patrickjm/truncateString?v=2";
import { comments as comments2 } from "https://esm.town/v/andreterron/comments";
export function receivedCommentsEmail(data) {
type Then<T> = T extends Promise<infer U> ? U : never;
let comments = data.data as Then<
ReturnType<typeof comments2>
>["data"];
const lis = comments.map((comment) => {
let name = `${comment.val.username}.${comment.val.name}`;
let valLink = `https://val.town/v/${name}`;
let commentLink = `${valLink}#comment-${comment.id}`;
return `<li>
<a href="${valLink}">${name}</a>
-
<a href="${commentLink}">${comment.author.username}</a>
:
${truncateString(comment.comment, 200)}
</li>`;
}).join("\n");
let ul = "<ul>" + lis + "</ul>";
return ul;
}
October 23, 2023