From 4f1c301a3de3048b9eddf93435d504544fafeaac Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Sat, 11 Jan 2025 16:33:58 +0000 Subject: [PATCH] Fix ts errors --- src/lib/util.ts | 10 ++++++---- src/pages/chess/[...page].astro | 1 - .../chess/tournament/[tournament]/[...page].astro | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/util.ts b/src/lib/util.ts index d195176..539e36d 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -1,3 +1,5 @@ +import type { CollectionEntry } from "astro:content"; + export function createSlug(title: string) { return title .trim() @@ -9,7 +11,7 @@ export function createSlug(title: string) { .replace(/^-+|-+$/g, '') } -export function sortedByDate(entry: any) { +export function sortedByDate(entry: C[]): C[] { return entry.sort((a, b) => extractDate(b.id).valueOf() - extractDate(a.id).valueOf()); } @@ -24,18 +26,18 @@ export function buildChessMetaTags(round?: number, board?: number) { return metaTags; } -export function createChessSlug(game: any) { +export function createChessSlug(game: CollectionEntry<"chess">) { return `${game.id.split("-").slice(0, 3).join("-")}_${game.data.white ?? ""}_${game.data.black ?? ""}` .toLowerCase() .replace(/\s+/g, "_") .split("/")[1]; } -export function createChessDescription(game: any) { +export function createChessDescription(game: CollectionEntry<"chess">) { return `Chess game played between ${game.data.white ?? "Bruno Mendes"} and ${game.data.black ?? "Bruno Mendes"}.`; } -export function createChessTitle(game: any) { +export function createChessTitle(game: CollectionEntry<"chess">) { return `${game.data.white ?? "Bruno Mendes"} ${game.data.whiteElo ? `(${game.data.whiteElo})` : ""} ${game.data.result} ${game.data.black ?? "Bruno Mendes"} ${game.data.blackElo ? `(${game.data.blackElo})` : ""}`; } diff --git a/src/pages/chess/[...page].astro b/src/pages/chess/[...page].astro index 2696ccf..481b6d1 100644 --- a/src/pages/chess/[...page].astro +++ b/src/pages/chess/[...page].astro @@ -6,7 +6,6 @@ import { buildChessMetaTags, createChessSlug, createChessTitle, - extractDate, sortedByDate, } from "../../lib/util"; import LargeTitle from "@components/LargeTitle.astro"; diff --git a/src/pages/chess/tournament/[tournament]/[...page].astro b/src/pages/chess/tournament/[tournament]/[...page].astro index 75e078e..9554fa3 100644 --- a/src/pages/chess/tournament/[tournament]/[...page].astro +++ b/src/pages/chess/tournament/[tournament]/[...page].astro @@ -7,7 +7,6 @@ import { capitalize, createChessSlug, createChessTitle, - extractDate, sortedByDate, } from "../../../../lib/util"; import LargeTitle from "@components/LargeTitle.astro";