master
 1import { define, Issue, PullRequest } from '#src'
 2
 3export default define({
 4  url: import.meta.url,
 5  badges: ['the-ultimate-question'] as const,
 6  present(data, grant) {
 7    const list: (Issue | PullRequest)[] = []
 8
 9    for (const issue of data.issues) {
10      if (issue.number == 42) list.push(issue)
11    }
12    for (const pull of data.pulls) {
13      if (pull.number == 42) list.push(pull)
14    }
15
16    if (list.length > 0) {
17      grant(
18        'the-ultimate-question',
19        'I found the answer to the ultimate question of life, the universe, and everything!',
20      ).evidence(list.map((x) => `- ${link(x)}`).join('\n'))
21    }
22  },
23})
24
25function link(x: Issue | PullRequest): string {
26  return `<a href="https://github.com/${x.repository.owner.login}/${x.repository.name}/issues/${x.number}">#${x.number}</a>`
27}