mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-07-05 15:06:53 +00:00
Update page.tsx
This commit is contained in:
parent
74d54ee9de
commit
618d6d8e16
@ -12,7 +12,7 @@ const CopyableCode = dynamic(() => import("@/components/CopyableCode"), { ssr: f
|
|||||||
|
|
||||||
const guidesDirectory = path.join(process.cwd(), "..", "guides")
|
const guidesDirectory = path.join(process.cwd(), "..", "guides")
|
||||||
|
|
||||||
// 🔹 Busca archivos Markdown dentro de subdirectorios
|
// 🔹 Función para buscar archivos Markdown dentro de subdirectorios
|
||||||
function findMarkdownFiles(dir: string, basePath = "") {
|
function findMarkdownFiles(dir: string, basePath = "") {
|
||||||
let files: { slug: string; path: string }[] = []
|
let files: { slug: string; path: string }[] = []
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ function findMarkdownFiles(dir: string, basePath = "") {
|
|||||||
files = files.concat(findMarkdownFiles(fullPath, relativePath))
|
files = files.concat(findMarkdownFiles(fullPath, relativePath))
|
||||||
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
||||||
files.push({
|
files.push({
|
||||||
slug: relativePath.replace(/\.md$/, "").replace(/\/index$/, ""), // 🔹 Quitamos `.md` y `index` si es necesario
|
slug: relativePath.replace(/\.md$/, ""), // 🔹 Quitamos la extensión `.md`
|
||||||
path: fullPath,
|
path: fullPath,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -36,17 +36,14 @@ function findMarkdownFiles(dir: string, basePath = "") {
|
|||||||
// 🔹 Obtiene el contenido de la guía
|
// 🔹 Obtiene el contenido de la guía
|
||||||
async function getGuideContent(slug: string) {
|
async function getGuideContent(slug: string) {
|
||||||
try {
|
try {
|
||||||
|
const decodedSlug = decodeURIComponent(slug) // 🔹 Solución: Decodificamos el slug para evitar `%2F`
|
||||||
const markdownFiles = findMarkdownFiles(guidesDirectory)
|
const markdownFiles = findMarkdownFiles(guidesDirectory)
|
||||||
|
|
||||||
let guideFile = markdownFiles.find((file) => file.slug === slug)
|
// 🔹 Buscamos el archivo dentro de subdirectorios
|
||||||
|
let guideFile = markdownFiles.find((file) => file.slug === decodedSlug)
|
||||||
// 🔹 Si no se encuentra, intentamos con `index.md` dentro de la carpeta
|
|
||||||
if (!guideFile) {
|
|
||||||
guideFile = markdownFiles.find((file) => file.slug === `${slug}/index`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!guideFile) {
|
if (!guideFile) {
|
||||||
console.error(`❌ No se encontró la guía: ${slug}`)
|
console.error(`❌ No se encontró la guía: ${decodedSlug}`)
|
||||||
return { content: "<p class='text-red-600'>Error: No se encontró la guía solicitada.</p>", metadata: null }
|
return { content: "<p class='text-red-600'>Error: No se encontró la guía solicitada.</p>", metadata: null }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user