import type React from "react" import fs from "fs" import path from "path" import matter from "gray-matter" import Link from "next/link" import Footer from "@/components/footer" const guidesDirectory = path.join(process.cwd(), "..", "guides") interface Guide { title: string description: string slug: string } function getGuides(): Guide[] { let guides: Guide[] = [] function findGuides(dir: string, basePath = "") { fs.readdirSync(dir, { withFileTypes: true }).forEach((entry) => { const fullPath = path.join(dir, entry.name) const relativePath = path.join(basePath, entry.name) if (entry.isDirectory()) { findGuides(fullPath, relativePath) } else if (entry.isFile() && entry.name.endsWith(".md")) { const slug = relativePath.replace(/\.md$/, "") // 🔹 Extraer metadatos usando gray-matter const fileContents = fs.readFileSync(fullPath, "utf8") const { data } = matter(fileContents) guides.push({ title: data.title || slug.replace(/_/g, " "), description: data.description || "No description available.", slug, }) } }) } findGuides(guidesDirectory) return guides } export default function GuidesPage() { const guides = getGuides() return (
Complementary guides to make the most of your Proxmox VE.
{guide.description}
))}