artesaos / seotools

SEO Tools for Laravel
MIT License
3.07k stars 503 forks source link

Append "Admin" to title #103

Closed ghost closed 6 years ago

ghost commented 6 years ago

The front-end of my website is using seotools for the seo and it's been working fantastic.

I'm in the middle of creating an admin panel for the website so I can easily manage the content on the go with the panel. I setup seotools for the admin panel, however the page titles are New Post - Brandy. Is there a way to append admin to the title so it would be something like New Post - Brandy Admin or New Post - Brandy's Admin?

It's fine if I can't, it's just been driving my OCD crazy and I've been unable to find a way to easily append the title, since I'm using the seotools for both front-end and back-end of the site.

tzurbaev commented 6 years ago

You can create custom middleware and attach it to all admin routes. Inside middleware's handle method override default titles:

<?php

namespace App\Http\Middleware;

class AdminMiddleware
{
    public function handle($request, \Closure $next)
    {
        config()->set('seotools.meta.defaults.title', config('seotools.meta.defaults.title').' Admin');
        config()->set('seotools.opengraph.defaults.title', config('seotools.opengraph.defaults.title').' Admin');

        return $next($request);
    }
ghost commented 6 years ago

@tzurbaev This worked amazingly!

Thanks a ton for the help, I really appreciate it!