<commit_before><?php 
  $menu = [
  /* 'menu-item-page-url' => [desired child pages (empty -> if none)] */
        '/'  => false,
        'blog'  => ['parent' => Page::findByPrimaryUri('blog'), 'visibileInNavigation'],
        'portfolio'  => [],
        'about'  => [],
    ];
    ?>

<?php if (isset($child_items) && ($child_items)) :?>
    <ul id="topnav" class="main-menu sm sm-simple">
      <?php foreach ($menu as $section => $criteria) : ?>
       <?php   
        $menu_item = Page::findByUri($section); 
        $menu_sub_items = empty($criteria) ? $getPages(['parent' => $menu_item, 'visibileInNavigation']) : $getPages($criteria); ?>
                    
       <?php   if(!empty($menu_sub_items)) : ?>

                <?php $has_children = ($criteria === false) ? false : count($menu_sub_items); ?>
       
            <li <?php if ($menu_item->is($page)): ?> class="active"<?php endif ?>>
            <a href="<?= $menu_item->url() ?>"><?= $menu_item->getTitle() ?><?php if ($has_children): ?><?php /* Add any toggler needed */ ?><?php endif ?>
            </a>
                <?php if($has_children) : ?>
              <ul class="sub-menu">
                      <?php foreach ($menu_sub_items as $p) : ?>
                      <li id="menu-item-<?= $p->getId() ?>" <?php if ($p->is($page)): ?> class="active"<?php endif ?>>
                          <a href="<?= $p->url() ?>" title="<?= $p->getTitle() ?>"> <?= $p->getTitle() ?></a>
                          </li>
                      <?php endforeach ?>
              </ul>
          <?php endif ?>
         </li>
            <?php endif ?>
       <?php endforeach ?>
    </ul>


<?php else : ?>
<ul id="topnav">
    <?php foreach ($getPages(['parent' => Page::findByPrimaryUri('/'), 'visibileInNavigation']) as $p): ?>
        <li><a href="<?= $p->url() ?>" <?php if ($p->is($page)): ?> class="active"<?php endif ?>><?= $p->getTitle() ?></a></li>
    <?php endforeach ?>
</ul>
<?php endif ?><commit_msg>Menu: fixed whitespace and fixed errors on new install when pages don't exist<commit_after><?php 
  $menu = [
        '/'  => false,
        'blog'  => ['parent' => Page::findByPrimaryUri('blog'), 'visibileInNavigation'],
        'portfolio'  => [],
        'about'  => [],
    ];
?>

<?php if (isset($child_items) && ($child_items)) :?>
    <ul id="topnav" class="main-menu sm sm-simple">
        <?php foreach ($menu as $section => $criteria) : ?>
            <?php   
                $menu_item = Page::findByUri($section); 
                $menu_sub_items = empty($criteria) ? $getPages(['parent' => $menu_item, 'visibileInNavigation']) : $getPages($criteria)
            ?>
                    
            <?php if ($menu_item && !empty($menu_sub_items)): ?>
                <?php $has_children = ($criteria !== false) ?>
       
                <li <?php if ($menu_item->is($page)): ?> class="active"<?php endif ?>>
                    <a href="<?= $menu_item->url() ?>">
                        <?= $menu_item->getTitle() ?>
                    </a>

                    <?php if ($has_children) : ?>
                        <ul class="sub-menu">
                            <?php foreach ($menu_sub_items as $p): ?>
                                <li id="menu-item-<?= $p->getId() ?>" <?php if ($p->is($page)): ?> class="active"<?php endif ?>>
                                    <a href="<?= $p->url() ?>" title="<?= $p->getTitle() ?>">
                                        <?= $p->getTitle() ?>
                                    </a>
                              </li>
                            <?php endforeach ?>
                        </ul>
                    <?php endif ?>
                </li>
            <?php endif ?>
       <?php endforeach ?>
    </ul>
<?php else : ?>
    <ul id="topnav">
        <?php foreach ($getPages(['parent' => Page::findByPrimaryUri('/'), 'visibileInNavigation']) as $p): ?>
            <li><a href="<?= $p->url() ?>" <?php if ($p->is($page)): ?> class="active"<?php endif ?>><?= $p->getTitle() ?></a></li>
        <?php endforeach ?>
    </ul>
<?php endif ?>
{'fraction_non_alphanumeric': 0.2210552027357108, 'fraction_numerical': 0.0, 'mean_word_length': 1.7575757575757576, 'pattern_counts': {'":': 0, '<': 102, '<?xml version=': 0, '>': 142, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7450238', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1223, 'n_words': 258}