mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-18 12:34:25 +08:00
22 lines
789 B
JavaScript
22 lines
789 B
JavaScript
const fs = require('fs').promises
|
|
|
|
const demoLoader = require('../loaders/naive-ui-demo-loader')
|
|
const docEntryLoader = require('../loaders/naive-ui-doc-entry-loader')
|
|
const docLoader = require('../loaders/naive-ui-doc-loader')
|
|
const mdLoader = require('../loaders/naive-ui-md-loader')
|
|
|
|
module.exports = async function getDemoByPath (path) {
|
|
if (path.endsWith('.demo.md')) {
|
|
const code = await fs.readFile(path, 'utf-8')
|
|
return demoLoader(code, path)
|
|
} else if (path.endsWith('.entry')) {
|
|
return docEntryLoader(path)
|
|
} else if (path.endsWith('.demo-entry.md')) {
|
|
const code = await fs.readFile(path, 'utf-8')
|
|
return docLoader(code, path)
|
|
} else if (path.endsWith('.md')) {
|
|
const code = await fs.readFile(path, 'utf-8')
|
|
return mdLoader(code, path)
|
|
}
|
|
}
|