src/Generator/Section.php
public function generate(PageCollection $pageCollection, \Closure $messageCallback)
    {
        $generatedPages = new PageCollection();
        $sections = [];

        // collects sections
        /* @var $page Page */
        foreach ($pageCollection as $page) {
            if ($page->getSection() != '') {
                $sections[$page->getSection()][] = $page;
            }
        }
        // adds node pages to collection
        if (count($sections) > 0) {
            $menuWeight = 100;
            foreach ($sections as $section => $pages) {
                if (!$pageCollection->has($section.'/')) {
                    usort($pages, 'PHPoole\Util::sortByDate');
                    $page = (new Page())
                        ->setId(Page::urlize(sprintf('%s/', $section)))
                        ->setPathname(Page::urlize(sprintf('%s', $section)))
                        ->setTitle(ucfirst($section))
                        ->setNodeType(NodeType::SECTION)
                        ->setVariable('pages', $pages)
                        ->setVariable('date', reset($pages)->getDate())
                        ->setVariable('menu', [
                            'main' => ['weight' => $menuWeight],
                        ]);
                    $generatedPages->add($page);
                }
                $menuWeight += 10;
            }
        }

        return $generatedPages;
    }
public function generate(PageCollection $pageCollection, \Closure $messageCallback)
    {
        $generatedPages = new PageCollection();
        $sections = [];

        // collects sections
        /* @var $page Page */
        foreach ($pageCollection as $page) {
            if ($page->getSection() != '') {
                $sections[$page->getSection()][] = $page;
            }
        }
        // adds node pages to collection
        if (count($sections) > 0) {
            $menuWeight = 100;
            foreach ($sections as $section => $pages) {
                if (!$pageCollection->has($section.'/')) {
                    usort($pages, 'PHPoole\Util::sortByDate');
                    $page = (new Page())
                        ->setId(Page::urlize(sprintf('%s/', $section)))
                        ->setPathname(Page::urlize(sprintf('%s', $section)))
                        ->setTitle(ucfirst($section))
                        ->setNodeType(NodeType::SECTION)
                        ->setVariable('pages', $pages)
                        ->setVariable('date', reset($pages)->getDate())
                        ->setVariable('menu', [
                            'main' => ['weight' => $menuWeight],
                        ]);
                    $generatedPages->add($page);
                }
                $menuWeight += 10;
            }
        }

        return $generatedPages;
    }
{@inheritdoc}