Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Test for both md and mdx

Terry Suttonead80901a0d9
diff --git a/apps/temp-docs/lib/docs.ts b/apps/temp-docs/lib/docs.ts
index 05c2fa79f4c..5f048630b4d 100644
--- a/apps/temp-docs/lib/docs.ts
+++ b/apps/temp-docs/lib/docs.ts
@@ -5,9 +5,24 @@ import matter from 'gray-matter'
const docsDirectory = process.cwd()
export function getDocsBySlug(slug: string) {
+ console.log('getDocsBySlug', { slug })
const realSlug = slug.replace(/\.mdx$/, '')
- let fullPath = join(docsDirectory, `${realSlug}.mdx`)
+ // files can either be .md or .mdx
+ // we need to check which one exists
+ let fullPath
+ let fullPathMD = join(docsDirectory, `${realSlug}.md`)
+ let fullPathMDX = join(docsDirectory, `${realSlug}.mdx`)
+
+ if (fs.existsSync(fullPathMD)) {
+ fullPath = fullPathMD
+ }
+
+ if (fs.existsSync(fullPathMDX)) {
+ fullPath = fullPathMDX
+ }
+
+ // if no match, 404
if (!fs.existsSync(fullPath)) {
console.log(`\nfile ${fullPath} not found, redirect to 404\n`)
fullPath = join(docsDirectory, 'docs/404.mdx')