'Facebook', 'instagram' => 'Instagram', 'tiktok' => 'TikTok', ]; private array $data; public function __construct() { $path = resource_path('stoic/content/settings.md'); $this->data = is_file($path) ? YamlFrontMatter::parse(file_get_contents($path))->matter() : []; } public function get(string $key, mixed $default = null): mixed { return filled($this->data[$key] ?? null) ? $this->data[$key] : $default; } /** * Absolute og:image URL for a Stoic image field value (the page's own, else * this file's default), or null. Image fields store a comma-separated list; * only the first is used. */ public function ogImageUrl(?string $pageImage = null): ?string { $filename = trim(explode(',', $pageImage ?: (string) $this->get('og_image', ''))[0]); return $filename === '' ? null : url(Stoic::image($filename, 'large')); } /** * Only the networks that have a URL set, in display order. * * @return list */ public function socialLinks(): array { $links = []; foreach (self::SOCIALS as $icon => $label) { if ($url = $this->get("{$icon}_url")) { $links[] = ['icon' => $icon, 'label' => $label, 'url' => $url]; } } return $links; } }