Skip to content

Commit

Permalink
Merge pull request #1263 from CodeCrowCorp/dev
Browse files Browse the repository at this point in the history
Feat: updated channel and profile SEO
  • Loading branch information
gagansuie authored May 23, 2024
2 parents 335d1ea + 28db98c commit 2281c3b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage-website",
"version": "0.2.16",
"version": "0.2.17",
"license": "GPL-3.0",
"private": true,
"type": "module",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/Channel/Stream/VideoItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@
{/if}
</label>
{#if showBanItem || showRoleItem}
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-200 rounded-box w-52">
<ul
tabindex="0"
class="dropdown-content dropdown-top menu p-2 shadow bg-base-100 rounded-box w-52">
{#if showRoleItem && !channel.bans.includes(video._id)}
<li>
<a on:click={() => toggleMod()}
Expand Down
4 changes: 3 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
</script>`}

<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@GaganSuie" />
<meta name="twitter:site" content={`@${$page.data.seo?.username || 'gagansuie'}`} />
<meta name="twitter:creator" content={`@${$page.data.seo?.username || 'gagansuie'}`} />
<meta
name="twitter:title"
content={$page.data.seo?.title || 'Mage - A collaborative streaming platform'} />
Expand All @@ -95,6 +96,7 @@
<meta name="twitter:image" content={$page.data.seo?.image || '%sveltekit.assets%/banner.png'} />
<meta name="twitter:image:alt" content={$page.data.seo?.imageAlt || 'Mage Banner'} />

<meta property="og:site_name" content="Mage" />
<meta property="og:type" content="website" />
<meta property="og:url" content={$page.data.seo?.url || 'https://mage.stream'} />
<meta
Expand Down
5 changes: 3 additions & 2 deletions src/routes/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ export const load = (async ({ params, url }) => {
}
return {
seo: {
title: profile.username?.toLowerCase(),
title: profile.displayName?.toLowerCase(),
description: profile.bio,
image: profile.avatar,
imageAlt: `${profile.username?.toLowerCase()} avatar`,
url: url.href
url: url.href,
username: profile.username?.toLowerCase()
},
profile: profile,
lazy: {
Expand Down
24 changes: 21 additions & 3 deletions src/routes/channel/[channelId]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
import { putImage } from '$lib/api'
import { get, putImage } from '$lib/api'
import { dataURLtoFile } from '$lib/utils'
import type { Actions } from './$types'
import { error } from '@sveltejs/kit'
import type { Actions, PageServerLoad } from './$types'

//TODO: get channel in server side and set SEO data
export const load = (async ({ params, url }) => {
if (!params.channelId) error(404)
const channel = await get(`channel?channelId=${params.channelId}`)
if (!channel || channel?.error) {
error(404)
}
return {
seo: {
title: channel.title,
description: channel.description,
image: channel.thumbnail || 'https://mage.stream/placeholder/programming-placeholder.jpg',
imageAlt: `channel thumbnail`,
url: url.href,
username: channel.username
},
channel
}
}) satisfies PageServerLoad

export const actions = {
'edit-channel': async ({ request, locals }) => {
Expand Down
4 changes: 3 additions & 1 deletion src/routes/channel/[channelId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import DrawerRestream from '$lib/components/Channel/Chat/DrawerRestream.svelte'
import DialogSponsor from '$lib/components/Channel/Chat/DialogSponsor.svelte'
import { is_feature_premium_enabled } from '$lib/stores/remoteConfigStore'
import type { PageData } from './$types'
export let data: PageData
let channel: any,
isDeleteModalOpen = false,
showEditChannelDrawer = false,
Expand Down Expand Up @@ -163,7 +165,7 @@
}
const loadChannel = async () => {
const chan = await get(`channel?channelId=${$page.params.channelId}`)
const chan = data.channel
chan.videoItems = []
const isOnboarded = await get(`plan/onboarded?userId=${chan.userId}`)
chan.isOnboarded = isOnboarded || false
Expand Down

0 comments on commit 2281c3b

Please sign in to comment.