From a7c3a88605df9cefcfe2c38439eed8b199c6b469 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mauguet Date: Wed, 11 Dec 2024 10:54:23 +0100 Subject: [PATCH] feat: remove unused file (#116) --- src/lib/server/solutions-mdx.ts | 47 --------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 src/lib/server/solutions-mdx.ts diff --git a/src/lib/server/solutions-mdx.ts b/src/lib/server/solutions-mdx.ts deleted file mode 100644 index e4db2544..00000000 --- a/src/lib/server/solutions-mdx.ts +++ /dev/null @@ -1,47 +0,0 @@ -// eslint-disable-next-line import/no-unresolved -import "server-only"; - -import { readdir } from "fs/promises"; -// eslint-disable-next-line import/named -import { cache } from "react"; - -export type SolutionMDX = typeof import("content/solutions/*.mdx"); - -type Imported = SolutionMDX & { - id: string; -}; - -/** - * Get all solutions from mdx files. - */ -export const getSolutions = async () => { - const ids = (await readdir("content/solutions/")).map(file => file.replace(".mdx", "")); - - const imported = ( - await Promise.all( - ids.map>(async id => ({ - ...((await import(`/content/solutions/${id}.mdx`)) as SolutionMDX), - id, - })), - ) - ) - .map(({ default: solutionComponent, frontmatter, id }) => ({ - solutionComponent, - frontmatter, - id, - })) - .sort((a, b) => Number(a.id) - Number(b.id)); - - return imported; -}; - -/** - * Get a solution by its id. - * - * @example getSolution("00") for RCU - */ -export const getSolution = cache(async (id: string) => { - const solutions = await getSolutions(); - - return solutions.find(solution => solution.id === id); -});