- Updated the documentation API endpoints to dynamically set the documentation directory based on the NODE_ENV variable, improving compatibility between development and production environments. - Enhanced error handling for file retrieval to ensure proper responses when files are not found or invalid. - Standardized import statements for consistency across the documentation files.
14 lines
420 B
JavaScript
14 lines
420 B
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
let docsDir = "";
|
|
if (process.env.NODE_ENV === "development") {
|
|
docsDir = path.resolve(process.cwd(), "content/documentation");
|
|
} else {
|
|
docsDir = path.resolve(process.cwd(), "../content/documentation");
|
|
}
|
|
const files = fs.readdirSync(docsDir)
|
|
.filter(file => file.endsWith('.md'))
|
|
return files
|
|
})
|