( slug: string, )
| 203 | const contentDir = join(process.cwd(), 'content', 'compare'); |
| 204 | |
| 205 | export async function getCompareData( |
| 206 | slug: string, |
| 207 | ): Promise<CompareData | null> { |
| 208 | try { |
| 209 | const filePath = join(contentDir, `${slug}.json`); |
| 210 | const fileContents = readFileSync(filePath, 'utf8'); |
| 211 | const data = JSON.parse(fileContents) as CompareData; |
| 212 | return { |
| 213 | ...data, |
| 214 | url: `/compare/${slug}`, |
| 215 | }; |
| 216 | } catch (error) { |
| 217 | console.error(`Error loading compare data for ${slug}:`, error); |
| 218 | return null; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | export async function getAllCompareSlugs(): Promise<string[]> { |
| 223 | try { |
no test coverage detected