public function getArchive()
    {
        $format = ($this->ArchiveType == 'Yearly') ? '%Y' : '%Y-%m';
        $publishDate = DB::get_conn()->formattedDatetimeClause('"PublishDate"', $format);
        $fields = [
            'PublishDate' => $publishDate,
            'Total' => "COUNT('\"PublishDate\"')"
        ];

        $stage = Versioned::get_stage();
        $suffix = ($stage === Versioned::LIVE) ? '_' . Versioned::LIVE : '';
        $query = SQLSelect::create($fields, '"BlogPost' . $suffix . '"')
            ->addGroupBy($publishDate)
            ->addOrderBy('"PublishDate" DESC')
            ->addWhere(['"PublishDate" <= ?' => DBDatetime::now()->Format(DBDatetime::ISO_DATETIME)]);

        $posts = $query->execute();
        $result = ArrayList::create();
        foreach ($posts as $post) {
            if ($this->ArchiveType == 'Yearly') {
                $year  = $post['PublishDate'];
                $month = null;
                $title = $year;
            } else {
                $date = DBDate::create();
                $date->setValue(strtotime($post['PublishDate']));

                $year  = $date->Format('y');
                $month = $date->Format('MM');
                $title = $date->Format('MMMM y');
            }

            $result->push(ArrayData::create([
                'Title' => $title,
                'Link' => Controller::join_links($this->Blog()->Link('archive'), $year, $month)
            ]));
        }

        $this->extend('updateGetArchive', $result);

        return $result;
    }