Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Kirby object to config function #25

Open
deanbot opened this issue Jul 4, 2020 · 0 comments
Open

Pass Kirby object to config function #25

deanbot opened this issue Jul 4, 2020 · 0 comments

Comments

@deanbot
Copy link

deanbot commented Jul 4, 2020

Passing $kirby to pedroborges.meta-tags.default|templates is helpful.

I.e. to differ metadata on the route used:

<?php
$config = array(
    // ...
    'pedroborges.meta-tags.default' => function ($page, $site, $kirby) {
    $template = $page->template()->name();
    if ($template == 'blog') {
        $isArchive = $kirby->route()->attributes()['pattern'] == 'blog/(:any)';
        if ($isArchive) {
            $description = '<Category Archive Description>';
        } else {
            $description = '<Blog Index Description>';
        }
    }
    return [
        // ...
        'meta' => [
            'description' => $description
        ],
    ]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant