public function build(Generator $generator)
    {
        $renderer = new DOMRenderer($generator, $this);
        $publisher = new Publisher($generator, $this);

        $pageManager = $this->loadPageManager($generator);
        while (!$pageManager->getQueue()->isEmpty()) {
            $page = $pageManager->getQueue()->dequeue();

            if ($pageManager->hasPage($page)) {
                continue;
            }

            // Parse the source file:
            $sourceFile = $pageManager->getSourceFile($page);

            // Register the page:
            $pageManager->addPage($page, $sourceFile);

            // Parse the content:
            $content = $renderer->renderContentElement($sourceFile->getContent());

            // And add the content to the publisher:
            $publisher->add($page, $content);
        }

        $publisher->publish();
    }