From 3f8fb2dd9301c40d444e1e45cbe15c4b11ae87c2 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 20 Dec 2023 14:17:35 -0500 Subject: [PATCH] Use the local version of the metadata.json instead of sourcing from github (#1320) Use the local version of the metadata.json instead of sourcing it from github main branch --- src/lib/game-saving/gallery.ts | 4 +++- src/pages/gallery/[filename].astro | 2 +- src/pages/gallery/index.astro | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/game-saving/gallery.ts b/src/lib/game-saving/gallery.ts index 6c49e74eea..7512771bf7 100644 --- a/src/lib/game-saving/gallery.ts +++ b/src/lib/game-saving/gallery.ts @@ -1,3 +1,5 @@ +import metadata from '../../../games/metadata.json' + export interface GameMetadata { filename: string title: string @@ -8,4 +10,4 @@ export interface GameMetadata { isNew: true | undefined } -export const getGalleryGames = async () => await fetch('https://raw.githubusercontent.com/hackclub/sprig/main/games/metadata.json').then((res) => res.json()) as GameMetadata[] \ No newline at end of file +export const getGalleryGames = () => metadata as GameMetadata[] \ No newline at end of file diff --git a/src/pages/gallery/[filename].astro b/src/pages/gallery/[filename].astro index 5ec4f6607c..6fec957e36 100644 --- a/src/pages/gallery/[filename].astro +++ b/src/pages/gallery/[filename].astro @@ -27,7 +27,7 @@ let tutorial: string[] | undefined = files ?.map(md => md.compiledContent()) if (tutorial.length == 0) tutorial = undefined -const games = await getGalleryGames() +const games = getGalleryGames() const metadata = games.find(game => game.filename === filename) const name = metadata?.title const authorName = metadata?.author diff --git a/src/pages/gallery/index.astro b/src/pages/gallery/index.astro index 741490019c..20fa6ece1b 100644 --- a/src/pages/gallery/index.astro +++ b/src/pages/gallery/index.astro @@ -9,7 +9,7 @@ import Gallery from "./gallery"; const session = await getSession(Astro.cookies); -const games = await getGalleryGames(); +const games = getGalleryGames(); const tags = [ ...new Set(games.reduce((p, c) => [...p, ...c.tags], [])), ];