Skip to content

Commit

Permalink
Fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes committed Jan 11, 2025
1 parent 08aff6b commit 4f1c301
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { CollectionEntry } from "astro:content";

export function createSlug(title: string) {
return title
.trim()
Expand All @@ -9,7 +11,7 @@ export function createSlug(title: string) {
.replace(/^-+|-+$/g, '')
}

export function sortedByDate(entry: any) {
export function sortedByDate<C extends { id: string }>(entry: C[]): C[] {
return entry.sort((a, b) => extractDate(b.id).valueOf() - extractDate(a.id).valueOf());
}

Expand All @@ -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})` : ""}`;
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/chess/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
buildChessMetaTags,
createChessSlug,
createChessTitle,
extractDate,
sortedByDate,
} from "../../lib/util";
import LargeTitle from "@components/LargeTitle.astro";
Expand Down
1 change: 0 additions & 1 deletion src/pages/chess/tournament/[tournament]/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
capitalize,
createChessSlug,
createChessTitle,
extractDate,
sortedByDate,
} from "../../../../lib/util";
import LargeTitle from "@components/LargeTitle.astro";
Expand Down

0 comments on commit 4f1c301

Please sign in to comment.