<!-- Quick Links Section -->
<?php

$current_slug = get_post_field('post_name', get_post());
$pages = get_pages_as_array();
$subpages = getSubpagesForSlug($pages, $current_slug);


if (count($subpages) > 0) { ?>

  <div class="py-4 px-2 lg:h-full">
    <ul class="grid grid-cols-1 lg:grid-cols-2 gap-2 lg:h-full place-items-stretch">
      <?php
      foreach ($subpages as $subpage) {

        $pageID = $subpage->ID;

      ?>

        <li class="category-cards flex rounded-md shadow-md relative overflow-hidden w-full" style="background-image: url('<?php echo get_template_directory_uri(); ?>/assets/images/bgs/internal/<?php echo $subpage->post_name ?>.png');">
          <a class="relative w-full py-8 px-4 space-y-2 lg:flex lg:flex-col lg:items-center lg:justify-center" href="<?php echo get_site_url() . '/' . $pages[$subpage->post_parent]['page']->post_name . '/' . $subpage->post_name ?>">

            <div class="bg-white bg-opacity-60 rounded-md py-2 px-4 lg:px-8">
              <h2 class="font-bold uppercase"><?php echo $subpage->post_title ?></h2>
            </div>

            <?php if (get_field('description', $pageID) != '') { ?>
              <p class="lg:text-center"><?php echo get_field('description', $pageID); ?></p>
            <?php } ?>
          </a>

        </li>

      <?php } ?>
    </ul>
  </div>

<?php }
