Move donator direct link logic to frontmatter

This commit is contained in:
Jorge Vargas 2025-02-24 22:41:31 -06:00
parent 16f2e520e7
commit 781a9ae216
2 changed files with 16 additions and 9 deletions

View file

@ -6,10 +6,10 @@ interface Props {
alt?: string
icon?: ImageMetadata
direct?: boolean
hasDirect?: boolean
}
const { href, alt, icon, direct = false } = Astro.props
const { permissions } = Astro.locals
const disabled = direct && !permissions.includes('SKIP_ADS')
const { href, alt, icon, direct = false, hasDirect = false } = Astro.props
const disabled = direct && !hasDirect
---
<a

View file

@ -15,6 +15,9 @@ import flyIcon from 'img/assets/fly-icon.png'
import ouoIcon from 'img/assets/ouo-icon.png'
const { id } = Astro.params
const { permissions } = Astro.locals
const hasDirect = permissions.includes('SKIP_ADS')
const album = await prismaClient.albums.findUnique({
where: { id: Number(id) },
include: {
@ -26,7 +29,12 @@ const album = await prismaClient.albums.findUnique({
animList: { select: { animation: { select: { id: true, title: true } } } },
stores: { select: { url: true, provider: true }, where: { NOT: { provider: 'SOON' } } },
discs: { select: { number: true, body: true } },
downloads: { select: { title: true, links: true } },
downloads: {
select: {
title: true,
links: { select: { id: true, url: true, url2: true, provider: true, directUrl: hasDirect } }
}
},
relatedAlbumList: { select: { relatedAlbum: { select: { id: true, title: true } } } }
}
})
@ -273,11 +281,10 @@ const { currentLocale } = Astro
{m.ouoIO()}
</DownloadBtn>
) : null}
{directUrl ? (
<DownloadBtn href={directUrl} direct server:defer>
{m.direct()}
</DownloadBtn>
) : null}
<DownloadBtn href={directUrl} direct hasDirect={hasDirect}>
{m.direct()}
</DownloadBtn>
</div>
</Fragment>
)