1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-16 01:23:15 +02:00
blog/src/components/Changelog/index.astro
Matthias Kretschmann c123dd9d68
Switch to astro-redirect-from (#830)
* astro-redirect-from prototype

* move out plugin

* switch to astro-redirect-from

* fixes

* new post: astro-redirect-from

* fix dependency

* test fixes

* downgrade and lock astro

* until fix for https://github.com/withastro/astro/issues/8649 has been released

* mention debug json file

* fix e2e test
2023-09-23 21:32:18 +01:00

51 lines
1.1 KiB
Plaintext

---
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>