-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.astro
50 lines (45 loc) · 1.12 KB
/
index.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
import { markdownToHtml } from '@lib/markdown'
import { getRepo } from '@lib/github'
import styles from './index.module.css'
type Props = {
repo: string
}
const { repo } = Astro.props as Props
const repoInfo = await getRepo(repo)
if (!repoInfo) {
console.info(`Repo ${repo} not found`)
return
}
const { url, object } = repoInfo
const changelogHtml = await markdownToHtml(
object.text.replace('### Changelog', '')
)
---
{
repoInfo ? (
<>
<h2>Changelog</h2>
<div class={styles.changelog} id="changelog">
<p class={styles.source}>
sourced from{' '}
<a href={`${url}/tree/main/CHANGELOG.md`}>
<code>{`${repo}:CHANGELOG.md`}</code>
</a>
</p>
<div class={styles.content} set:html={changelogHtml} />
</div>
<button class="link" id="changelog-all">
Show all
</button>
</>
) : null
}
<script>
const changelog = document.querySelector('#changelog')
const button = document.querySelector('#changelog-all')
button?.addEventListener('click', () => {
changelog?.classList.add('all')
button?.remove()
})
</script>