src/scripts/tasks/site.js
function renderDocs(SITE_DIR, name) {
    const env = templates.configure();
    const nav = navigation.getNavigation();
    const components = _.find(nav.children, { id: name });

    components.children.forEach(component => {
        const dirPath = Path.join(SITE_DIR, component.path);
        console.log(dirPath);
        const htmlPath = Path.join(dirPath, 'index.html');
        const rawDir = Path.join(SITE_DIR, 'raw', component.id);

        const componentData = findComponent(component.id);
        componentData.template = pathTrimStart(
            Path.join(component.path, `${component.id}.html`),
        );

        const html = env.render('component.html', {
            navigation: nav,
            component: componentData,
            config: config,
            tokens: getTokens(),
        });

        mkdirp.sync(rawDir);
        mkdirp.sync(dirPath);

        fs.writeFileSync(htmlPath, html, 'utf-8');

        if (componentData.flavours) {
            componentData.flavours.forEach(flavour => {
                if (flavour.states) {
                    flavour.states.forEach(variant => {
                        const state = getStateFromFlavour(
                            componentData,
                            flavour.id,
                            variant.id,
                        );
                        const stateDir = Path.join(
                            rawDir,
                            flavour.id,
                            variant.id,
                        );
                        renderState(env, stateDir, nav, componentData, state);
                    });
                }

                if (flavour.state) {
                    const stateDir = Path.join(rawDir, flavour.id);
                    renderState(
                        env,
                        stateDir,
                        nav,
                        componentData,
                        flavour.state,
                    );
                }
            });
        }
    });
}
function renderDocs(SITE_DIR, name) {
    const env = templates.configure();
    const nav = navigation.getNavigation();
    const components = _.find(nav.children, { id: name });

    components.children.forEach(component => {
        const dirPath = Path.join(SITE_DIR, component.path);
        console.log(dirPath);
        const htmlPath = Path.join(dirPath, 'index.html');
        const rawDir = Path.join(SITE_DIR, 'raw', component.id);

        const componentData = findComponent(component.id);
        componentData.template = pathTrimStart(
            Path.join(component.path, `${component.id}.html`),
        );

        const html = env.render('component.html', {
            navigation: nav,
            component: componentData,
            config: config,
            tokens: getTokens(),
        });

        mkdirp.sync(rawDir);
        mkdirp.sync(dirPath);

        fs.writeFileSync(htmlPath, html, 'utf-8');

        if (componentData.flavours) {
            componentData.flavours.forEach(flavour => {
                if (flavour.states) {
                    flavour.states.forEach(variant => {
                        const state = getStateFromFlavour(
                            componentData,
                            flavour.id,
                            variant.id,
                        );
                        const stateDir = Path.join(
                            rawDir,
                            flavour.id,
                            variant.id,
                        );
                        renderState(env, stateDir, nav, componentData, state);
                    });
                }

                if (flavour.state) {
                    const stateDir = Path.join(rawDir, flavour.id);
                    renderState(
                        env,
                        stateDir,
                        nav,
                        componentData,
                        flavour.state,
                    );
                }
            });
        }
    });
}
function renderDocs ( SITE_DIR , name ) { const env = templates . configure ( ) ; const nav = navigation . getNavigation ( ) ; const components = _ . find ( nav . children , { id : name } ) ; components . children . forEach ( component => { const dirPath = Path . join ( SITE_DIR , component . path ) ; console . log ( dirPath ) ; const htmlPath = Path . join ( dirPath , 'index.html' ) ; const rawDir = Path . join ( SITE_DIR , 'raw' , component . id ) ; const componentData = findComponent ( component . id ) ; componentData . template = pathTrimStart ( Path . join ( component . path , ` ${ component . id } ` ) , ) ; const html = env . render ( 'component.html' , { navigation : nav , component : componentData , config : config , tokens : getTokens ( ) , } ) ; mkdirp . sync ( rawDir ) ; mkdirp . sync ( dirPath ) ; fs . writeFileSync ( htmlPath , html , 'utf-8' ) ; if ( componentData . flavours ) { componentData . flavours . forEach ( flavour => { if ( flavour . states ) { flavour . states . forEach ( variant => { const state = getStateFromFlavour ( componentData , flavour . id , variant . id , ) ; const stateDir = Path . join ( rawDir , flavour . id , variant . id , ) ; renderState ( env , stateDir , nav , componentData , state ) ; } ) ; } if ( flavour . state ) { const stateDir = Path . join ( rawDir , flavour . id ) ; renderState ( env , stateDir , nav , componentData , flavour . state , ) ; } } ) ; } } ) ; }
Renders the documentation for each component
Renders the documentation for each component