1
0
Fork 0

Create and use new component for creators

This commit is contained in:
Korbs 2024-06-27 23:16:07 -04:00
parent 85f787725e
commit 95609eae11
No known key found for this signature in database
2 changed files with 88 additions and 12 deletions

View file

@ -0,0 +1,59 @@
---
const {
Name,
Avatar,
Link,
Platform,
Banner,
Followers
} = Astro.props
---
<a href={Link} class={'search-creator'}>
<div class="search-creator-media">
<p>{Followers}</p>
<img class="scm-banner" alt={Name + "'s banner"} src={Banner}/>
<img class="scm-avatar" alt={Name + "'s avatar"} src={Avatar}/>
</div>
<div class="search-creator-meta">
<p><strong>{Name}</strong></p>
</div>
</a>
<style lang="scss">
.search-creator {
background: #181818;
border-radius: 12px;
padding: 4px;
text-decoration: none;
* {cursor: var(--pointer-cursor) !important}
.search-creator-media {
position: relative;
p {
position: absolute;
right: 24px;
background: black;
border-radius: 1rem;
padding: 6px 12px;
}
.scm-banner {
aspect-ratio: 16/9;
width: 360px;
height: 140px;
object-fit: cover;
border-radius: 12px;
}
.scm-avatar {
position: absolute;
left: 12px;
bottom: -32px;
border-radius: 3rem;
border: 2px white solid;
width: 80px;
}
}
.search-creator-meta {
padding-left: 104px;
}
}
</style>

View file

@ -4,6 +4,7 @@ import Base from '@layouts/Default.astro'
// Components // Components
import Video from '@components/common/VideoItem.astro' import Video from '@components/common/VideoItem.astro'
import Creator from '@components/search/Creator.astro'
// Environment Variables // Environment Variables
const DEFAULT_INVIDIOUS_INSTANCE = import.meta.env.DEFAULT_INVIDIOUS_INSTANCE const DEFAULT_INVIDIOUS_INSTANCE = import.meta.env.DEFAULT_INVIDIOUS_INSTANCE
@ -15,6 +16,10 @@ const InvidiousResponse = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE +
.catch((error) => { .catch((error) => {
console.log(error) console.log(error)
}) })
const InvidiousChannelsResponse = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + "/api/v1/search?q=" + Query + '&type=channel')
.catch((error) => {
console.log(error)
})
const TwitchResponse = await fetch('https://' + DEFAULT_SAFETWITCH_BACKEND + "/api/search/?query=" + Query) const TwitchResponse = await fetch('https://' + DEFAULT_SAFETWITCH_BACKEND + "/api/search/?query=" + Query)
.catch((error) => { .catch((error) => {
@ -22,6 +27,7 @@ const TwitchResponse = await fetch('https://' + DEFAULT_SAFETWITCH_BACKEND + "/a
}) })
const InvidiousData = await InvidiousResponse.json() const InvidiousData = await InvidiousResponse.json()
const InvidiousChannelsData = await InvidiousChannelsResponse.json()
const TwitchData = await TwitchResponse.json() const TwitchData = await TwitchResponse.json()
--- ---
@ -29,25 +35,36 @@ const TwitchData = await TwitchResponse.json()
<div class="page-title"> <div class="page-title">
<h2>Search</h2> <h2>Search</h2>
</div> </div>
<p>Twitch Channels related to "{Query}"</p> <p>YouTube creators related to "{Query}"</p>
<div class="twitch-channels">
{InvidiousChannelsData.map((channel) =>
<Creator
Name={channel.author}
Avatar={channel.authorThumbnails[1].url}
Link={'/channel/youtube/' + channel.authorId}
Platform="YouTube"
Banner={channel.authorThumbnails[1].url}
Followers={channel.subCount}
/>
)}
</div>
<p>Twitch creators related to "{Query}"</p>
<div class="twitch-channels"> <div class="twitch-channels">
{TwitchData.data.channels.map((channel) => {TwitchData.data.channels.map((channel) =>
<a href={'/channel/twitch/' + channel.username} class="channel"> <Creator
<img id="backgound"src={channel.pfp}/> Name={channel.username}
<div class="tc-info"> Avatar={channel.pfp}
<img src={channel.pfp}/> Link={'/channel/twitch/' + channel.username}
<div> Platform="Twitch"
<h2>{channel.username}</h2> Banner={channel.pfp}
<p>{channel.about}</p> Followers={channel.followers}
</div> />
</div>
</a>
)} )}
</div> </div>
<p>Twitch Live streams with the tag "{Query}"</p> <p>Twitch Live streams with the tag "{Query}"</p>
<div class="twitch-channels"> <div class="twitch-channels">
{TwitchData.data.relatedChannels.map((channel) => {TwitchData.data.relatedChannels.map((channel) =>
<a href={'/channel/twitch/' + channel.username} class="channel-stream" data-astro-reload <a href={'/channel/twitch/' + channel.username} class="channel-stream" data-astro-reload>
<img class="stream-preview" src={channel.stream.preview}/> <img class="stream-preview" src={channel.stream.preview}/>
<div class="channel-info"> <div class="channel-info">
<img src={channel.pfp}/> <img src={channel.pfp}/>