improvements

pull/7/head
pikax 5 years ago
parent d6cc5f0c0b
commit 12d4473d7c

@ -33,6 +33,17 @@ export async function bundle(
if (id === '/@siteData') { if (id === '/@siteData') {
return `export default ${JSON.stringify(JSON.stringify(config.site))}` return `export default ${JSON.stringify(JSON.stringify(config.site))}`
} }
if (id === '/@components') {
const componentsFiles = (
await fs.readdir(config.componentDir)
).map((x) => [
path.basename(x, path.extname(x)),
path.extname(x).slice(1)
])
return `export default ${JSON.stringify(componentsFiles)}`
}
// compile md into vue src for .md.vue virtual files // compile md into vue src for .md.vue virtual files
if (id.endsWith('.md')) { if (id.endsWith('.md')) {
const filePath = id.replace(/\.vue$/, '') const filePath = id.replace(/\.vue$/, '')

@ -24,11 +24,8 @@ export function createResolver(
if (publicPath.startsWith('/@theme')) { if (publicPath.startsWith('/@theme')) {
return path.join(themeDir, publicPath.replace(/^\/@theme\/?/, '')) return path.join(themeDir, publicPath.replace(/^\/@theme\/?/, ''))
} }
if (publicPath.startsWith('/@components/index')) { if (publicPath === '/@components') {
return path.join( return publicPath
componentDir,
publicPath.replace(/^\/@components\/?/, '')
)
} }
if (publicPath.startsWith('/@components')) { if (publicPath.startsWith('/@components')) {
return path.join( return path.join(

Loading…
Cancel
Save