Skip to content

Commit

Permalink
some more tests with play slug
Browse files Browse the repository at this point in the history
  • Loading branch information
ceitine committed Oct 21, 2024
1 parent ceafdad commit 218d8c4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
8 changes: 1 addition & 7 deletions src/routes/games/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
return true;
}
function resolvePath(src: string) {
return src.startsWith('http://') || src.startsWith('https://')
? src
: `/blogs/${$page.params.slug}/${src}`;
}
let initialGame: Game;
</script>

Expand All @@ -30,7 +24,7 @@
{/if}

{#if initialGame.logo}
<meta property="og:image" content="https://smallfi.sh/{resolvePath(initialGame.logo)}" />
<meta property="og:image" content="https://smallfi.sh/{initialGame.logo}" />
{/if}
{/if}
</svelte:head>
28 changes: 19 additions & 9 deletions src/routes/play/[slug]/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
<script lang="ts">
import { page } from '$app/stores';
import { Games, type Game } from '$lib/types/Games';
import { onMount } from 'svelte';
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
function getGameFromIdent(): Boolean {
const cullIdent = (ident: string): string => {
if (ident.startsWith('fish.')) ident = ident.substring(5);
return ident;
};
function getGameFromIdent(): boolean {
const slug = $page.params.slug;
const decodedName = decodeURI(slug);
const target = Games.find(
(g) => g.sboxIdent?.toLowerCase() === decodedName.toLocaleLowerCase()
(g) =>
cullIdent(g.sboxIdent ?? 'fuck-you-kid').toLowerCase() === decodedName.toLocaleLowerCase()
);
if (target == null) return false;
game = target;
return true;
}
if (browser) {
window.location.href = `steam://run/590830//-rungame ${game.sboxIdent}`;
goto('/');
}
function resolvePath(src: string) {
return src.startsWith('http://') || src.startsWith('https://')
? src
: `/blogs/${$page.params.slug}/${src}`;
return true;
}
let game: Game;
Expand All @@ -32,7 +40,9 @@
{/if}

{#if game.logo}
<meta property="og:image" content="https://smallfi.sh/{resolvePath(game.logo)}" />
<meta property="og:image" content="https://smallfi.sh/{game.logo}" />
{/if}
{/if}
</svelte:head>

<slot />
2 changes: 0 additions & 2 deletions src/routes/play/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export function load({ params }) {
message: 'Not found'
});
}

throw redirect(302, `steam://run/590830//-rungame ${game.sboxIdent}`);
}

export const prerender = true;
Empty file.

0 comments on commit 218d8c4

Please sign in to comment.