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
|
alt?: string
|
||||||
icon?: ImageMetadata
|
icon?: ImageMetadata
|
||||||
direct?: boolean
|
direct?: boolean
|
||||||
|
hasDirect?: boolean
|
||||||
}
|
}
|
||||||
const { href, alt, icon, direct = false } = Astro.props
|
const { href, alt, icon, direct = false, hasDirect = false } = Astro.props
|
||||||
const { permissions } = Astro.locals
|
const disabled = direct && !hasDirect
|
||||||
const disabled = direct && !permissions.includes('SKIP_ADS')
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<a
|
<a
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ import flyIcon from 'img/assets/fly-icon.png'
|
||||||
import ouoIcon from 'img/assets/ouo-icon.png'
|
import ouoIcon from 'img/assets/ouo-icon.png'
|
||||||
|
|
||||||
const { id } = Astro.params
|
const { id } = Astro.params
|
||||||
|
const { permissions } = Astro.locals
|
||||||
|
const hasDirect = permissions.includes('SKIP_ADS')
|
||||||
|
|
||||||
const album = await prismaClient.albums.findUnique({
|
const album = await prismaClient.albums.findUnique({
|
||||||
where: { id: Number(id) },
|
where: { id: Number(id) },
|
||||||
include: {
|
include: {
|
||||||
|
|
@ -26,7 +29,12 @@ const album = await prismaClient.albums.findUnique({
|
||||||
animList: { select: { animation: { select: { id: true, title: true } } } },
|
animList: { select: { animation: { select: { id: true, title: true } } } },
|
||||||
stores: { select: { url: true, provider: true }, where: { NOT: { provider: 'SOON' } } },
|
stores: { select: { url: true, provider: true }, where: { NOT: { provider: 'SOON' } } },
|
||||||
discs: { select: { number: true, body: true } },
|
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 } } } }
|
relatedAlbumList: { select: { relatedAlbum: { select: { id: true, title: true } } } }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -273,11 +281,10 @@ const { currentLocale } = Astro
|
||||||
{m.ouoIO()}
|
{m.ouoIO()}
|
||||||
</DownloadBtn>
|
</DownloadBtn>
|
||||||
) : null}
|
) : null}
|
||||||
{directUrl ? (
|
|
||||||
<DownloadBtn href={directUrl} direct server:defer>
|
<DownloadBtn href={directUrl} direct hasDirect={hasDirect}>
|
||||||
{m.direct()}
|
{m.direct()}
|
||||||
</DownloadBtn>
|
</DownloadBtn>
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue