@docfy/ember-vite
Version:
Vite plugin for Docfy Ember integration with @embroider/vite
35 lines (34 loc) • 1.25 kB
JavaScript
/**
* Process a page's demo components and extract them for inline generation
* This replaces the need for the ember plugin system
*/
export function processPageDemos(page) {
const demoComponents = [];
// Check if the page has demo components from the core plugins
const pluginDemoComponents = page.pluginData?.demoComponents;
if (Array.isArray(pluginDemoComponents)) {
pluginDemoComponents.forEach((component) => {
if (component.name && component.chunks) {
demoComponents.push({
name: {
pascalCase: component.name.pascalCase,
dashCase: component.name.dashCase
},
chunks: component.chunks.map((chunk) => ({
ext: chunk.ext,
code: chunk.code,
type: chunk.type
}))
});
}
});
}
return demoComponents;
}
/**
* Check if a page has demo components that need processing
*/
export function hasPageDemos(page) {
const pluginDemoComponents = page.pluginData?.demoComponents;
return Array.isArray(pluginDemoComponents) && pluginDemoComponents.length > 0;
}