From 1e7eddcb82b6dddb6d51e440e31b4c4ec121256f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Sun, 8 Jan 2023 18:18:11 +0100 Subject: [PATCH] Accept an Astro argument instead of using this --- src/utils/getPlaylistLayoutProps.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/getPlaylistLayoutProps.ts b/src/utils/getPlaylistLayoutProps.ts index 5a06a72..3c38e54 100644 --- a/src/utils/getPlaylistLayoutProps.ts +++ b/src/utils/getPlaylistLayoutProps.ts @@ -3,8 +3,8 @@ import { decode } from 'html-entities'; import type { AstroGlobal } from 'astro'; import type { PlaylistSnapshot } from '../models/playlist-snapshot'; -export async function getPlaylistLayoutProps(this: Readonly) { - const { playlistId } = this.params; +export async function getPlaylistLayoutProps(Astro: Readonly) { + const { playlistId } = Astro.params; let playlist: PlaylistSnapshot | null = null; let title = ''; @@ -18,7 +18,7 @@ export async function getPlaylistLayoutProps(this: Readonly) { if (!githubResponse.ok) { const errorMessage = githubResponse.status === 404 - ? "This playlist doesn't exist" + ? "Astro playlist doesn't exist" : "Failed to fetch playlist's data"; throw new Error(errorMessage); @@ -34,7 +34,7 @@ export async function getPlaylistLayoutProps(this: Readonly) { } catch (e) { const expectedErrorMessages = [ "Failed to fetch playlist's data", - "This playlist doesn't exist" + "Astro playlist doesn't exist" ]; const [miscError] = expectedErrorMessages; const errorMessage = (e as Error).message; @@ -44,8 +44,8 @@ export async function getPlaylistLayoutProps(this: Readonly) { ? errorMessage : miscError; - this.response.status = description === miscError ? 500 : 404; - this.response.statusText = errorMessage; + Astro.response.status = description === miscError ? 500 : 404; + Astro.response.statusText = errorMessage; } return { playlist, title, description };