1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6declare(strict_types=1);
7
8namespace App\Libraries\Opengraph\Wiki;
9
10use App\Libraries\Opengraph\OpengraphInterface;
11use App\Models\Wiki\Page;
12
13class PageOpengraph implements OpengraphInterface
14{
15 public function __construct(private Page $page)
16 {
17 }
18
19 public function get(): array
20 {
21 if (!$this->page->isVisible()) {
22 return [];
23 }
24
25 return [
26 'description' => $this->page->getTextPreview(),
27 'title' => $this->page->title(),
28 ];
29 }
30}