<?php

return [
    // Kirby configuration settings
    'home' => 'accueil',
    'panel' => [
        'language' => 'fr'
    ],
    // Meta Knight plugin options
    'diesdasdigital.meta-knight' => [
        'siteTitleAfterPageTitle' => false,
        'siteTitleAsHomePageTitle' => true,
        'separator' => ' | ',
        'metaAuthor' => false
    ],
    // Sitemapper plugin options
    'kirbyzone.sitemapper' => [
        'intro' => false,
        'byLine' => 'Sitemap automatically generated by Sitemapper, by <a href="https://github.com/kirbyzone" target="_blank">Kirbyzone</a>.'
    ],
    // Hooks
    'hooks' => [
        'file.create:after' => function($file) {
            // Populate file_type field with $file->type() method after file creation
            if ($file->type()) {
                $file->update([
                    'file_type' => $file->type()
                ]);
            }
        },
        'page.update:after' => function($newPage) {
            // Populate page og_image and twitter_image fields with page meta_image field value after page update
            if ($newPage->meta_image()) {
                $newPage->update([
                    'og_image' => $newPage->meta_image()->value(),
                    'twitter_image' => $newPage->meta_image()->value()
                ]);
            }
            // Populate site meta_description, og_image and twitter_image fields with home page meta_description, og_image and twitter_image fields value after home page update
            if ($newPage->template()->name() === 'home' && $newPage->meta_description()) {
                $this->site()->update([
                    'meta_description' => $newPage->meta_description()->value(),
                    'og_image' => $newPage->og_image()->value(),
                    'twitter_image' => $newPage->twitter_image()->value()
                ]);
            }
        }
    ]
];
