This commit is contained in:
2026-01-19 19:29:44 +01:00
parent 2feb73b982
commit 6797303628
15 changed files with 406 additions and 18 deletions

View File

@@ -32,3 +32,17 @@ export async function getPageBySlug(slug: string, locale: string): Promise<PageM
content,
};
}
export async function getAllPages(locale: string): Promise<PageMdx[]> {
const pagesDir = path.join(process.cwd(), 'data', 'pages', locale);
if (!fs.existsSync(pagesDir)) return [];
const files = fs.readdirSync(pagesDir);
const pages = await Promise.all(
files
.filter(file => file.endsWith('.mdx'))
.map(file => getPageBySlug(file.replace(/\.mdx$/, ''), locale))
);
return pages.filter((p): p is PageMdx => p !== null);
}