<commit_before><?php

namespace Gen;

class Blog
{
    protected $util;

    public function __construct(Util $util)
    {
        $this->util = $util;
    }

    public function getIndex($dir, $skip = []) {

        $out = ['blogs' => []];

        foreach ($this->util->scan($dir, 'twig') as $entry) {
            if (!in_array($entry['file'], $skip)) {
                if (preg_match('#content(.*+)#', $entry['path'], $results)) {

                    $meta = [];
                    $metaFile = $this->util->replaceExtension($entry['file'], 'meta.php');
                    if (file_exists($entry['path'] . '/' . $metaFile)) {
                        $meta = (array) include $entry['path'] . '/' . $metaFile;
                    }

                    $partUrl = $results[1];
                    $file = $this->util->replaceExtension($entry['file'], 'html');
                    $title = ucfirst(str_replace('-', ' ', $this->util->replaceExtension($file, '')));

                    $out['blogs'][] = [
                        'title' => $title,
                        'path' => $path . '/' . $file
                    ];
                }
            }
        }
        return $out;
    }
}<commit_msg>Breaks the building of and the retrieving of the blog index into two.<commit_after><?php

namespace Gen;

class Blog
{
    protected $util;
    protected $index = [];

    public function __construct(Util $util)
    {
        $this->util  = $util;
        $this->index = ['blogs' => []];
    }

    public function buildIndex($dir, $skip = []) {
        foreach ($this->util->scan($dir, 'twig') as $entry) {
            if (!in_array($entry['file'], $skip)) {
                if (preg_match('#content(.*+)#', $entry['path'], $results)) {

                    $meta = [];
                    $metaFile = $this->util->replaceExtension($entry['file'], 'meta.php');
                    if (file_exists($entry['path'] . '/' . $metaFile)) {
                        $meta = (array) include $entry['path'] . '/' . $metaFile;
                    }

                    $partUrl = $results[1];
                    $file = $this->util->replaceExtension($entry['file'], 'html');

                    if (isset($meta['title'])) {
                        $title = $meta['title'];
                    } else {
                        $title = ucfirst(str_replace('-', ' ', $this->util->replaceExtension($file, '')));
                    }

                    $this->index['blogs'][] = [
                        'title' => $title,
                        'url' => $partUrl . '/' . $file,
                        'path' => $entry['path'],
                        'file' => $entry['file'],
                        'meta' => $meta
                    ];
                }
            }
        }
        return $this;
    }

    public function getIndex()
    {
        return $this->index;
    }
}
{'fraction_non_alphanumeric': 0.1824160609207338, 'fraction_numerical': 0.0006922810661128419, 'mean_word_length': 1.3306451612903225, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2921697', 'n_tokens_mistral': 826, 'n_tokens_neox': 768, 'n_words': 148}