mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Move donator direct link logic to frontmatter
This commit is contained in:
parent
16f2e520e7
commit
781a9ae216
2 changed files with 16 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
<DownloadBtn href={directUrl} direct hasDirect={hasDirect}>
|
||||
{m.direct()}
|
||||
</DownloadBtn>
|
||||
) : null}
|
||||
</div>
|
||||
</Fragment>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue