feat: add spoiler shortcodes

This commit is contained in:
grassblock 2025-05-17 12:14:27 +08:00
parent c55f49270a
commit 98ee7a3527
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,47 @@
---
const { tip = '' } = Astro.props
---
{/* TODO: make it work in paragraph wrapped elements */}
<span class="spoiler" title={tip}>
<slot/>
</span>
<style>
.spoiler {
background-color: #252525;
color: #252525;
transition: color 0.5s;
width: fit-content;
}
.spoiler:hover {
color: #ffffff;
}
/* fix blockquotes */
.spoiler blockquote {
color: #252525;
transition: color 0.5s;
}
.spoiler blockquote:hover {
color: #ffffff;
}
/* fix code */
.spoiler code pre {
color: #252525;
transition: color 0.5s;
}
.spoiler code pre:hover {
color: #ffffff;
}
/* fix list bullet*/
.spoiler li::marker {
color: #252525;
transition: color 0.5s;
}
.spoiler:hover li::marker {
color: #ffffff;
}
</style>

View file

@ -4,9 +4,14 @@ description: 'This is a test page'
---
import BlogRoll from "../../components/shortcodes/BlogRoll.astro"
import FediStatuses from "../../components/shortcodes/FediStatuses.astro"
import Spoiler from "../../components/shortcodes/Spoiler.astro"
testestestest
<BlogRoll/>
<Spoiler tip="Spoiler Title">
~~This is the content of the spoiler.~~
</Spoiler>
<FediStatuses instanceDomain='portal.gb0.dev' userId='me' />